Task scheduling method and device, electronic equipment and storage medium

By combining the preprocessing of the main control processor and the configuration parameters of the data block scheduling, the problem of unbalanced computing load in artificial intelligence chips is solved, achieving efficient load balancing and improved computing efficiency, which is suitable for heterogeneous framework scenarios.

CN118963967AActive Publication Date: 2024-11-15SHANGHAI BIREN TECH CO LTD

Patent Information

Application Number
CN202411225259.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-02
Publication Date
2024-11-15
Estimated Expiration
2044-09-02

AI Technical Summary

Technical Problem

In existing technologies, artificial intelligence chips suffer from uneven computational load and low computational efficiency during task scheduling, leading to idle computing resources or inefficient computation.

Method used

The main control processor preprocesses the target computation tasks of the artificial intelligence operators, obtains different data block scheduling configuration parameters, and determines the coordinates of the target data block that matches the number of available computing units, and executes the sub-computation tasks to achieve load balancing and efficient computing.

Benefits of technology

It improves the computational efficiency of artificial intelligence operators, avoids processor idleness, and expands the applicable scenarios for operator task scheduling, especially in heterogeneous framework scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118963967A_ABST
    Figure CN118963967A_ABST
Patent Text Reader

Abstract

The invention provides a task scheduling method and device, electronic equipment and a storage medium, and the method comprises the steps: responding to a task scheduling instruction, and obtaining different data block scheduling configuration parameters after the target calculation task of an artificial intelligence operator is preprocessed; each data block scheduling configuration parameter is provided by the main control processor; and based on each data block scheduling configuration parameter, determining a plurality of target data block coordinates matched with the number of the currently available calculation units, and executing a sub-calculation task for processing the target data blocks corresponding to the plurality of target data block coordinates. Scheduling is carried out by combining parameters such as the number of the available computing units, the better load balancing effect is achieved, meanwhile, the processors can be prevented from being in the idle state as far as possible, it is ensured that each processor has better computing efficiency, the artificial intelligence operator performance is improved, and the system performance is improved. And meanwhile, an interactive heterogeneous framework scene between the main control processor at the front end and the artificial intelligence chip at the rear end is combined, so that the application scene of operator task scheduling is expanded.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a task scheduling method, device, electronic device and storage medium. Background Art

[0002] At present, operators with large computational workloads such as matrix multiplication and convolution are common operator types on artificial intelligence chips, and artificial intelligence chips usually need to process the computational tasks of related operators during the training and reasoning of artificial intelligence models. Therefore, in order to speed up the training efficiency or reasoning efficiency of artificial intelligence models, a task scheduling system can be pre-set on the artificial intelligence chip, and the task scheduling system is used to schedule the computational tasks of operators called in model reasoning or model training. Therefore, how to achieve efficient and load-balanced task scheduling has become a key issue that needs to be solved urgently.

[0003] In the related art, the artificial intelligence chip first divides the computing task into rows or columns to obtain multiple data blocks containing sub-computing tasks, and then uses each computing unit to calculate the corresponding data block respectively; since the computing task is divided in a simple way, the task amount in the multiple data blocks obtained by the division is unevenly distributed. Therefore, when the task division process and the task scheduling process are both implemented on the artificial intelligence chip, there is a technical problem that the computing load is unbalanced and the computing efficiency is very low when each computing unit calculates the sub-computing tasks in the corresponding data block. Summary of the invention

[0004] The present invention provides a task scheduling method, device, electronic device and storage medium to solve the defects of unbalanced computing load and low computing efficiency in the task scheduling process of existing artificial intelligence operators. Scheduling in combination with parameters such as the number of available computing units has a better load balancing effect, and can also avoid processors from being idle as much as possible, ensuring that each processor has better computing efficiency, improving the performance of artificial intelligence operators, and at the same time combining the heterogeneous framework scenario of interaction between the front-end main control processor and the back-end artificial intelligence chip also expands the applicable scenarios of operator task scheduling.

[0005] The present invention provides a task scheduling method, which is applied to an artificial intelligence chip that runs an artificial intelligence algorithm, and the method comprises the following steps.

[0006] In response to the task scheduling instruction, different data block scheduling configuration parameters after preprocessing of the target computing task of the artificial intelligence operator are obtained; each of the data block scheduling configuration parameters is provided by the main control processor.

[0007] Based on the data block scheduling configuration parameters, multiple target data block coordinates that match the number of currently available computing units are determined, and sub-computing tasks for processing the target data blocks corresponding to each of the multiple target data block coordinates are executed.

[0008] According to a task scheduling method provided by the present invention, the method determines multiple target data block coordinates that match the number of currently available computing units based on each of the data block scheduling configuration parameters, including: executing the following steps for each thread block with the same number as the currently available computing units: determining the thread block family number of the thread block family based on the linear index of the thread block and the thread block family size of the thread block family corresponding to the thread block; determining the scheduling area size corresponding to the thread block family based on the thread block family number and each of the data block scheduling configuration parameters; determining the target data block coordinates that need to be processed by the thread block corresponding to the available computing unit based on the scheduling area size and the position offset of the thread block in the corresponding thread block family.

[0009] According to a task scheduling method provided by the present invention, the thread block family number of the thread block family is determined based on the linear index of the thread block and the thread block family size of the thread block family corresponding to the thread block, including: determining the thread block family size based on the row size of the thread block family and the column size of the thread block family; determining the thread block family number based on the linear index and the thread block family size.

[0010] According to a task scheduling method provided by the present invention, the determining of the scheduling region size corresponding to the thread block family based on the thread block family number and each of the data block scheduling configuration parameters comprises: when each of the data block scheduling configuration parameters comprises the number of thread block families contained in each row when the thread blocks are scheduled in a row direction, determining the row number where the thread block family is located based on the integer division operation result of the thread block family number and the number of thread block families contained in each row; determining the column number where the thread block family is located based on the modulus operation result of the thread block family number and the number of thread block families contained in each row; determining the scheduling region size based on the row number and the column number; or, when each of the data block scheduling configuration parameters comprises the number of thread block families contained in each column when the thread blocks are scheduled in a column direction, determining the column number where the thread block family is located based on the integer division operation result of the thread block family number and the number of thread block families contained in each column; determining the row number where the thread block family is located based on the modulus operation result of the thread block family number and the number of thread block families contained in each column; determining the scheduling region size based on the row number and the column number.

[0011] According to a task scheduling method provided by the present invention, the determining of the target data block coordinates that the thread block needs to process corresponding to the available computing unit based on the scheduling region size and the position offset of the thread block in the corresponding thread block family includes: determining the data block row coordinates that the thread block needs to process corresponding to the available computing unit based on the data block row size that the thread block needs to process corresponding to the available computing unit, the row size of the thread block family, the row number of the scheduling region size, and the row offset of the thread block in the corresponding thread block family; determining the data block column coordinates that the thread block needs to process corresponding to the available computing unit based on the data block column size that the thread block needs to process corresponding to the available computing unit, the column size of the thread block family, the column number of the scheduling region size, and the column offset of the thread block in the corresponding thread block family; and determining the data block row coordinates and the data block column coordinates as the target data block coordinates that the thread block needs to process corresponding to the available computing unit.

[0012] According to a task scheduling method provided by the present invention, the step of obtaining, in response to a task scheduling instruction, scheduling configuration parameters of different data blocks after preprocessing of a target computing task of an artificial intelligence operator includes: In response to the task scheduling instruction, based on the target task scheduling parameters and target data storage instructions carried in the task scheduling instruction, and the mapping relationship between the task scheduling parameters-data storage instructions-data block scheduling configuration parameter data packets, a target data block scheduling configuration parameter data packet is obtained, and the target data block scheduling configuration parameter data packet contains the different data block scheduling configuration parameters; wherein the mapping relationship is established based on the different data block scheduling configuration parameter data packets and different data storage instructions determined by the main control processor after pre-processing the computing tasks of different types of artificial intelligence operators.

[0013] According to a task scheduling method provided by the present invention, the main control processor is used to execute the following steps for each computing task: aligning the computing tasks in sequence based on the data block size, thread block family size and data block scheduling parameters to obtain updated computing tasks; dividing the updated computing tasks based on the data block size, data block scheduling direction and the number of currently available computing units to obtain a data block scheduling configuration parameter data packet corresponding to the computing task; storing the data block scheduling configuration parameter data packet in an immediate value manner or a register manner to generate a data storage instruction corresponding to the computing task.

[0014] According to a task scheduling method provided by the present invention, the execution and processing of the sub-computing tasks of the target data blocks corresponding to the multiple target data block coordinates respectively includes: processing each of the sub-computing tasks when the multiple target data block coordinates all belong to the current batch of target data block coordinates and do not exceed the target scale of the target computing task; based on the processing completion mark, re-determining the next batch of target data block coordinates in the multiple data blocks into which the target computing task is divided; taking all the data block coordinates contained in the next batch of target data block coordinates as new target data block coordinates, and repeating the above steps; until there is at least one invalid data block that exceeds the target scale among the re-determined multiple new target data block coordinates.

[0015] The present invention also provides a task scheduling device, which is applied to an artificial intelligence chip that runs an artificial intelligence algorithm. The device includes: a parameter acquisition unit and a task scheduling unit.

[0016] The parameter acquisition unit is used to respond to the task scheduling instruction and obtain the different data block scheduling configuration parameters after preprocessing the target computing task of the artificial intelligence operator; each of the data block scheduling configuration parameters is provided by the main control processor.

[0017] The task scheduling unit is used to determine multiple target data block coordinates that match the number of currently available computing units based on the data block scheduling configuration parameters, and execute sub-computing tasks for processing the target data blocks corresponding to the multiple target data block coordinates.

[0018] The present invention also provides an electronic device, comprising a main control processor and an artificial intelligence chip running an artificial intelligence algorithm connected in the form of a heterogeneous framework; the artificial intelligence chip is used to respond to a task scheduling instruction to obtain different data block scheduling configuration parameters after preprocessing of the target computing task of the artificial intelligence operator; based on each of the data block scheduling configuration parameters, determine a plurality of target data block coordinates that match the number of currently available computing units, and execute sub-computing tasks of processing the target data blocks corresponding to each of the plurality of target data block coordinates; the main control processor is used to provide each of the data block scheduling configuration parameters to the artificial intelligence chip.

[0019] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the task scheduling method described in any one of the above is implemented.

[0020] The task scheduling method, device, electronic device and storage medium provided by the present invention, wherein the task scheduling method, when responding to the task scheduling instruction, the artificial intelligence chip first obtains the different data block scheduling configuration parameters after preprocessing of the target computing task of the artificial intelligence operator, and then further determines the multiple target data block coordinates matching the number of currently available computing units based on the scheduling configuration parameters of each data block, and executes the sub-computation tasks of processing the target data blocks corresponding to the multiple target data block coordinates. Since the different data block scheduling configuration parameters after preprocessing of the target computing task of the artificial intelligence operator are provided by the main control processor, the main control processor at the front end calculates the data block coordinates of the required processing data block for each available computing unit in the artificial intelligence chip and executes the corresponding sub-computation tasks, so as to quickly and efficiently achieve the task scheduling purpose of the artificial intelligence operator task, and the entire task scheduling process is scheduled in combination with the number of available computing units and other parameters, which has a better load balancing effect, and can also avoid the processor from being in an idle state as much as possible, ensuring that each processor has better computing efficiency, improving the performance of the artificial intelligence operator, and at the same time, combining the heterogeneous framework scenario of the interaction between the main control processor at the front end and the artificial intelligence chip at the back end also expands the applicable scenario of operator task scheduling. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0022] Figure 1 It is a flowchart of the task scheduling method provided by the present invention.

[0023] Figure 2A It is one of the target scheduling direction schematic diagrams provided by the present invention.

[0024] Figure 2B This is the second target scheduling direction schematic diagram provided by the present invention.

[0025] Figure 3 It is a schematic diagram of the relationship between the target data block scheduling parameters provided by the present invention and the linear index and data block coordinates of the thread block.

[0026] Figure 4 It is a block diagram of the matrix multiplication calculation task provided by the present invention.

[0027] Figure 5 This is a schematic diagram of the dynamic scheduling provided by the present invention.

[0028] Figure 6 It is a structural schematic diagram of the task scheduling device provided by the present invention.

[0029] Figure 7 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0030] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0031] In the embodiments of the present invention, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B may be singular or plural. In the textual description of the present invention, the character " / " generally indicates that the previous and next associated objects are in an "or" relationship. In addition, it should be noted that the serial numbers themselves, such as "first", "second", etc., used to distinguish the objects described in the present invention are only used to distinguish the objects described, and do not have any order or technical meaning.

[0032] At present, operators with large computational workloads such as Matrix matmul and Convolution are common operator types on artificial intelligence chips, and artificial intelligence chips usually need to process the computational tasks of related operators during the training and reasoning of artificial intelligence models. Therefore, in order to speed up the training efficiency or reasoning efficiency of artificial intelligence models, a task scheduling system can be pre-set on the artificial intelligence chip, and the task scheduling system is used to schedule the computational tasks of operators called in model reasoning or model training. Therefore, how to achieve efficient and load-balanced task scheduling has become a key issue that needs to be solved urgently.

[0033] In the related art, the artificial intelligence chip first divides the computing task by rows or columns to obtain multiple data blocks containing sub-computing tasks respectively, and then uses each computing unit to calculate the corresponding data block respectively; since the computing task is divided in a simple way, the task amount in the multiple data blocks obtained by the division is unevenly distributed. In this way, when the task division process and the task scheduling process are both implemented on the artificial intelligence chip, there are technical problems such as unbalanced computing load and low computing efficiency in the process of each computing unit calculating the sub-computing tasks in the corresponding data block. For example, there is a computing unit that only calculates certain rows or columns of the matrix, resulting in idle computing resources, or avoiding idle computing resources and resulting in inefficient calculations within the data block.

[0034] In order to solve the above technical problems, the present invention provides a task scheduling method, device, electronic device and storage medium, which are scheduled in combination with parameters such as the number of available computing units to obtain a better load balancing effect, while also avoiding the processor from being idle as much as possible, ensuring that each processor has better computing efficiency, and improving the performance of artificial intelligence operators. At the same time, the heterogeneous framework scenario of interaction between the front-end main control processor and the back-end artificial intelligence chip also expands the applicable scenarios of operator task scheduling.

[0035] Combine the following Figure 1-Figure 7 The task scheduling method, device, electronic device and storage medium of the present invention are described, wherein the execution subject of the task scheduling method is a back-end artificial intelligence chip, which has at least a task scheduling function and can be called an artificial intelligence accelerator or computing card, that is, a module specifically used to process a large number of computing tasks in artificial intelligence applications, such as GPU (Graphics Processing Unit), TPU (Tensor Processing Unit), NPU (Neural network Processing Unit), DPU (Deeplearning Processing Unit), APU (Accelerated Processing Unit), and GPGPU (General-Purpose computing on Graphics Processing Unit). Furthermore, the execution subject of the task scheduling method can also be applied to a task scheduling device set in an artificial intelligence chip, and the task scheduling device can be implemented by software, hardware or a combination of the two. The task scheduling method is described below by taking the execution subject of the task scheduling method as an artificial intelligence chip with at least a task scheduling function as an example.

[0036] In order to facilitate understanding of the task scheduling method provided by the embodiment of the present invention, the task scheduling method provided by the present invention will be described in detail below through the following exemplary embodiments. It is understood that the following exemplary embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments.

[0037] Reference Figure 1 , is a flow chart of the task scheduling method provided by the present invention, such as Figure 1 As shown, the task scheduling method includes the following steps 110 and 120.

[0038] Step 110, in response to the task scheduling instruction, obtain the scheduling configuration parameters of different data blocks after preprocessing of the target computing task of the artificial intelligence operator; the scheduling configuration parameters of each data block are provided by the main control processor.

[0039] Among them, the task scheduling instructions can be instructions automatically generated when the artificial intelligence operator is called during the artificial intelligence model training or reasoning process.

[0040] Artificial intelligence operators can be operators with large computational workloads, such as matrix multiplication operators, convolution operators, and activation operators.

[0041] The target computing task is determined by the artificial intelligence operator. For example, when the artificial intelligence operator is a matrix multiplication operator, the target computing task is a matrix multiplication task; or, when the artificial intelligence operator is a convolution operator, the target computing task is a convolution task.

[0042] The number of artificial intelligence operators is the same as the number of preprocessing times and corresponds one to one.

[0043] The target computing task of each artificial intelligence operator is preprocessed to obtain a set of data block scheduling configuration parameters, and the preprocessing process of each target computing task is run in the front-end main control processor. Its purpose is to simplify the task scheduling process in the artificial intelligence chip and assist the artificial intelligence chip to quickly and accurately calculate the data block coordinate results obtained by splitting the target computing task.

[0044] Each preprocessing may include but is not limited to an alignment operation, a task splitting operation, and a storage instruction generation operation.

[0045] The main control processor may be a processor having at least other functions such as alignment operation, task splitting operation and storage instruction generation operation, such as a main control chip, a main control module, a central processing unit (CPU), an advanced reduced instruction set computer (ARM) processor and an X86 processor.

[0046] Different data block scheduling configuration parameters may include but are not limited to the target computing tasks of the artificial intelligence operator, the number of data blocks contained in each row after being divided by the currently available computing units, the number of data blocks contained in each column, and the number of data blocks contained in the surface area, as well as the number of thread block clusters contained in each row and the number of thread blocks contained in each column under different scheduling directions for multiple thread blocks; the number of thread blocks is the same as the number of currently available computing units.

[0047] Specifically, when the artificial intelligence chip responds to the task scheduling instruction, it first obtains the different data block scheduling configuration parameters after preprocessing the target computing task of the artificial intelligence operator. The acquisition method can be to directly read a set of data block scheduling configuration parameters corresponding to the target computing task from its memory when a set of data block scheduling configuration parameters corresponding to different computing tasks provided by the main control processor is pre-stored in the artificial intelligence chip memory; or, it can also be called from the cloud server when a set of data block scheduling configuration parameters corresponding to different computing tasks provided by the main control processor is pre-stored in the cloud server; or, the artificial intelligence chip can also feed back the parameter acquisition instruction carrying the target computing task to the front-end main control processor through communication transmission or copying, so that the main control processor can obtain a corresponding set of data block scheduling configuration parameters after preprocessing the target computing task, and send the set of data block scheduling configuration parameters to the artificial intelligence chip. The present invention does not make specific limitations on this.

[0048] Step 120: Based on the scheduling configuration parameters of each data block, determine multiple target data block coordinates that match the number of currently available computing units, and execute sub-computing tasks for processing the target data blocks corresponding to each of the multiple target data block coordinates.

[0049] The multiple target data block coordinates may be some of the multiple data block coordinates obtained after task segmentation of the target computing task.

[0050] The artificial intelligence chip is pre-configured with a graphics processing unit (GPU) architecture, which includes a series of streaming multiprocessors (SM), each of which is composed of multiple streaming processors, cores or threads. For example, the GPU architecture contains 132 SMs, and when each SM has 64 streaming processors, the total number of streaming processors can be as high as 8448, ensuring that the artificial intelligence chip has the ability to process massive data and parallel computing.

[0051] Specifically, the artificial intelligence chip can calculate the coordinates of multiple target data blocks that need to be processed synchronously in each cycle based on the scheduling configuration parameters of different data blocks after preprocessing of the target computing tasks; and the number of target data block coordinates that need to be processed synchronously in each cycle is the same as the number of currently available computing units (streaming multiprocessors) in the artificial intelligence chip. For example, when the number of currently available computing units is 16, each cycle requires synchronous calculation of the sub-computing tasks of each target data block of the 16 target data block coordinates.

[0052] It should be noted that, considering that a large number of data blocks divided by the target computing task can form a data block area, and multiple target data blocks can be selected in sequence by row, column or other specified methods in the data block area for synchronous processing, until at least one of the multiple target data blocks selected at a certain time does not belong to the data block area, only some target data blocks belonging to the data block area need to be synchronously processed; thereby completing the task scheduling process of the artificial intelligence operator.

[0053] The task scheduling method provided by the present invention, when responding to the task scheduling instruction, the artificial intelligence chip first obtains the different data block scheduling configuration parameters after preprocessing of the target computing task of the artificial intelligence operator, and then further determines multiple target data block coordinates matching the number of currently available computing units based on the scheduling configuration parameters of each data block, and executes the sub-computation tasks of processing the target data blocks corresponding to the multiple target data block coordinates. Since the different data block scheduling configuration parameters after preprocessing of the target computing task of the artificial intelligence operator are provided by the main control processor, the main control processor at the front end calculates the data block coordinates of the required processing data block for each available computing unit in the artificial intelligence chip and executes the corresponding sub-computation tasks, so as to quickly and efficiently achieve the task scheduling purpose of the artificial intelligence operator task, and the whole task scheduling process is combined with the number of available computing units and other parameters for scheduling, which has a better load balancing effect, and can also avoid the processor from being in an idle state as much as possible, ensuring that each processor has better computing efficiency, improving the performance of the artificial intelligence operator, and at the same time, the heterogeneous framework scenario of the interaction between the main control processor at the front end and the artificial intelligence chip at the back end also expands the applicable scenario of operator task scheduling.

[0054] Based on the above Figure 1 In the task scheduling method shown, in an exemplary embodiment, in step 120, the artificial intelligence chip determines multiple target data block coordinates that match the number of currently available computing units based on the scheduling configuration parameters of each data block, and the specific determination process can be implemented through the following steps.

[0055] The following steps are performed for each thread block with the same number of available compute units: First, based on the linear index of the thread block and the thread block family size of the thread block in the corresponding thread block family, the thread block family number of the thread block in the corresponding thread block family is determined; further, based on the thread block family number of the thread block in the corresponding thread block family and the scheduling configuration parameters of each data block, the scheduling area size corresponding to the thread block family is determined; then, based on the scheduling area size and the position offset of the thread block in the corresponding thread block family, the target data block coordinates required to be processed by the available computing unit corresponding to the thread block are determined.

[0056] Specifically, the artificial intelligence chip can initiate the same number of thread blocks according to the number of currently available computing units, and multiple thread blocks can be presented in a matrix form; in order to facilitate more convenient and efficient subsequent task scheduling, multiple thread blocks in matrix form can be flattened into a one-dimensional thread block array. Therefore, each thread block in the one-dimensional thread block array has a unique linear index (linear_index), and each thread block resides on an available computing unit inside the artificial intelligence chip to execute a sub-computing task corresponding to a target data block.

[0057] There may be multiple thread block families, and each thread block family may consist of at least one thread block; for example, the number of thread blocks in each thread block family may be 1, 2, 4, or 8, etc. Therefore, when the linear index of each thread block is determined and the size is known, the size of each thread block family is also determined.

[0058] Based on this, for multiple thread blocks with the same number as the currently available computing units, when the linear index of one of the thread blocks and the thread block family size of the thread block family corresponding to the thread block are known, the thread block family number of the thread block family can be determined, and then combined with the scheduling configuration parameters of each data block, the scheduling area size corresponding to the thread block family can be determined. The scheduling area size can be an area composed of the size of the row and the size of the column when scheduling in the row direction. At this time, the size of the row is determined based on the data block scheduling configuration parameter of the number of thread block families contained in each row; or, it can also be an area composed of the size of the column and the size of the row when scheduling in the column direction. At this time, the size of the column is determined based on the data block scheduling configuration parameter of the number of thread block families contained in each column.

[0059] Since the position offset of each thread block in its respective thread block family is determined, the coordinates of the target data block to be processed by the available computing unit corresponding to the thread block can be determined based on the position offset of one of the thread blocks in the corresponding thread block family and the scheduling region size determined based on the thread block.

[0060] In an example embodiment, the artificial intelligence chip determines the thread block family number of the thread block family based on the linear index of the thread block and the thread block family size of the thread block corresponding to the thread block. The specific determination process can be implemented through the following steps.

[0061] First, the thread block family size is determined based on the row size of the thread block family and the column size of the thread block family; then, the thread block family number is determined based on the linear index and the thread block family size.

[0062] Specifically, the thread block cluster size is calculated by formula (1).

[0063] cluster_size=cluster_row*cluster_col (1).

[0064] In formula (1), cluster_size represents the size of the thread block cluster, cluster_row represents the row size of the thread block cluster, cluster_col represents the column size of the thread block cluster, and * represents the multiplication operation.

[0065] The thread block family number is calculated by formula (2).

[0066] cluster_id=linear_index / cluster_size (2).

[0067] In formula (1), cluster_id represents the thread block cluster number, linear_index represents the linear index, and / represents the integer division operation.

[0068] In an example embodiment, the artificial intelligence chip determines the scheduling region size corresponding to the thread block family based on the thread block family number and the scheduling configuration parameters of each data block, and the determination process is implemented through the following steps.

[0069] In the case where each data block scheduling configuration parameter includes the number of thread block families contained in each row when multiple thread blocks are scheduled in a row direction, first, based on the integer division result of the thread block family number and the number of thread block families contained in each row, the row number where the thread block family is located is determined; further, based on the remainder operation result of the thread block family number and the number of thread block families contained in each row, the column number where the thread block family is located is determined; then, based on the row number and the column number, the scheduling region size is determined; or, in the case where each data block scheduling configuration parameter includes the number of thread block families contained in each column when multiple thread blocks are scheduled in a column direction, first, based on the integer division result of the thread block family number and the number of thread block families contained in each column, the column number where the thread block family is located is determined; further, based on the remainder operation result of the thread block family number and the number of thread block families contained in each column, the row number where the thread block family is located is determined; then, based on the row number and the column number, the scheduling region size is determined.

[0070] Specifically, for multiple thread blocks that are the same as the number of currently available computing units, the different data block scheduling configuration parameters after preprocessing of the target computing task of the artificial intelligence operator may include the number of thread block families contained in each row and the number of thread blocks contained in each column when multiple thread blocks are scheduled in a row direction, or may also include the number of thread block families contained in each column and the number of thread blocks contained in each row when multiple thread blocks are scheduled in a column direction.

[0071] The following takes the number of thread block clusters cluster_number_per_row contained in each row when multiple thread blocks are scheduled in the row direction as an example to determine the row number and column number of the thread block cluster.

[0072] Exemplarily, the row number of the thread block family is calculated by dividing the thread block family number by the number of thread block families contained in each row according to formula (3), and the column number of the thread block family is calculated by dividing the thread block family number by the number of thread block families contained in each row according to formula (4).

[0073] row_id=cluster_id / cluster_number_per_row (3).

[0074] col_id=cluster_id%cluster_number_per_row (4).

[0075] In formula (3) and formula (4), row_id represents the row number of the thread block cluster, col_id represents the column number of the thread block cluster, cluster_id represents the thread block cluster number, / represents the integer division operation; % represents the remainder operator, which is used to calculate the remainder after dividing two numbers.

[0076] It should be noted that, when taking the number of thread block clusters cluster_number_per_col contained in each column when multiple thread blocks are scheduled in the column direction as an example, the column number of the thread block cluster and the row number of the thread block cluster can also be calculated according to equations (5) and (6).

[0077] col_id=cluster_id / cluster_number_per_col (5).

[0078] row_id=cluster_id%cluster_number_per_col (6).

[0079] At this time, the scheduling area size corresponding to the thread block family can be determined based on the row number of the thread block family and the column number of the thread block family, that is, the area size corresponding to the thread block family where the thread block is located can be determined. Specifically, the area obtained by multiplying row_id and col_id can be used as the scheduling area size.

[0080] In an example embodiment, the artificial intelligence chip determines the coordinates of the target data block that needs to be processed by the available computing unit corresponding to the thread block based on the scheduling area size and the position offset of the thread block in the corresponding thread block family. The specific determination process can be determined by the following steps.

[0081] First, based on the row size of the data block that needs to be processed by the available computing unit corresponding to the thread block, the row size of the thread block family, the row number of the scheduling region size, and the row offset of the thread block in the corresponding thread block family, the row coordinates of the data block that needs to be processed by the available computing unit corresponding to the thread block are determined; further, based on the column size of the data block that needs to be processed by the available computing unit corresponding to the thread block, the column number of the thread block family, the column size of the scheduling region size, and the column offset of the thread block in the corresponding thread block family, the column coordinates of the data block that needs to be processed by the available computing unit corresponding to the thread block are determined; then, the data block row coordinates and the data block column coordinates are determined as the target data block coordinates that need to be processed by the available computing unit corresponding to the thread block.

[0082] Specifically, the row coordinates tile_row_coord of the data block that needs to be processed by the available computing unit corresponding to the thread block are calculated according to formula (7), and the column coordinates tile_col_coord of the data block that needs to be processed by the available computing unit corresponding to the thread block are calculated according to formula (8).

[0083] tile_row_coord=tile_row*(cluster_row*row_id+row_offset) (7).

[0084] tile_col_coord=tile_col*(cluster_col*col_id+col_offset) (8).

[0085] In equations (7) and (8), tile_row represents the row size of the data block that needs to be processed by the available computing units corresponding to the thread block, tile_col represents the column size of the data block that needs to be processed by the available computing units corresponding to the thread block, cluster_row represents the row size of the thread block cluster where the thread block is located, and cluster_col represents the column size of the thread block cluster where the thread block is located; row_id represents the row number of the scheduling region size, that is, the row number of the thread block cluster; col_id represents the column number of the scheduling region size, that is, the column number of the thread block cluster; row_offset represents the row offset of the thread block in the corresponding thread block cluster, and col_offset represents the column offset of the thread block in the corresponding thread block cluster.

[0086] Based on the above Figure 1 In the task scheduling method shown, in an exemplary embodiment, step 110 can be specifically implemented through the following steps.

[0087] In response to the task scheduling instruction, based on the target task scheduling parameters and target data storage instructions carried in the task scheduling instruction, and the mapping relationship between the task scheduling parameters-data storage instructions-data block scheduling configuration parameter data packets, a target data block scheduling configuration parameter data packet is obtained, and the target data block scheduling configuration parameter data packet contains different data block scheduling configuration parameters.

[0088] Among them, the mapping relationship is established based on different data block scheduling configuration parameter data packets and different data storage instructions determined by the main control processor after pre-processing the computing tasks of different types of artificial intelligence operators.

[0089] The target task scheduling parameters include the target scheduling direction and the target data block scheduling parameters.

[0090] The target scheduling direction can be the scheduling direction of multiple target data blocks that need to be processed in each cycle among the multiple data blocks obtained after segmentation of the target computing task; for example, scheduling by row or scheduling by column; and the target scheduling direction can be manually specified or automatically determined by the task scheduling system built into the artificial intelligence chip based on the scale of the target computing task.

[0091] For example, refer to Figure 2A and Figure 2B The target scheduling direction diagram is shown in Figure 2A and Figure 2B As shown, when each loop needs to process 16 target data blocks, Figure 2A AlongN is the 16 target data blocks scheduled by row, wave0~wave5 are the coordinates of the 16 target data blocks that are cycled 6 times and scheduled by row in each cycle; Figure 2BAlongM is the scheduling of 16 target data blocks by column, and wave0~wave5 are the 16 target data block coordinates that are cycled 6 times and scheduled by column in each cycle.

[0092] The target data block scheduling parameter can be expressed as a Swizzle size, which is used to characterize the mapping relationship between the linear index of the thread block and the data block coordinates in multiple thread blocks with the same number as the currently available computing units, and the specific value of the target data block scheduling parameter can be manually specified.

[0093] For example, refer to Figure 3 The schematic diagram of the relationship between the target data block scheduling parameters and the linear index and data block coordinates of the thread block is shown in Figure 3 In the example, cluster shape indicates the shape of thread blocks, wave 0 tile~wave3 tile indicates multiple data blocks that need to be processed synchronously in each of the four loops, problem block shape indicates the shape of data blocks, and oob indicates out-of-band data. Figure 3 As shown, when 16 target data blocks need to be processed in each loop, if the Swizzle size is 1, each loop first schedules 1 target data block along the column direction, and then schedules along the row direction until 16 target data blocks are scheduled; if the Swizzle size is 2, each loop first schedules 2 target data blocks along the column direction, and then schedules along the row direction until 16 target data blocks are scheduled; if the Swizzle size is 4, each loop first schedules 4 target data blocks along the column direction, and then schedules along the row direction until 16 target data blocks are scheduled; if the Swizzle size is 8, each loop first schedules 8 target data blocks along the column direction, and then schedules along the row direction until 16 target data blocks are scheduled.

[0094] The target data storage instruction may be a storage instruction generated when storing different data block scheduling configuration parameters as immediate numbers, or may be a storage instruction generated when storing different data block scheduling configuration parameters as registers; the target data storage instruction may specifically be a computer program instruction generated by a manually specified immediate number storage method, recorded as a static kernel program; or may be a computer program instruction automatically generated by a manually specified register storage method, recorded as a dynamic kernel program.

[0095] It should be noted that in the process of generating programs running on artificial intelligence chips, dynamic kernel programs or static kernel programs can be generated according to the configuration. Dynamic kernel programs are compatible with different computing scales and have strong versatility or compatibility; static kernel programs can pre-calculate the required different data block scheduling configuration parameters in the central processor and reflect them in the corresponding computer program instructions in the form of immediate numbers, thereby avoiding calculations on certain artificial intelligence chips and having better performance.

[0096] Specifically, when an artificial intelligence operator is called during the process of running an artificial intelligence model for training or reasoning, the corresponding target task scheduling parameters and target data storage instructions can be determined for the artificial intelligence operator, and then the task scheduling instructions can be automatically generated based on them.

[0097] When the artificial intelligence chip responds to the task scheduling instruction, the mapping relationship between the task scheduling parameter-data storage instruction-data block scheduling configuration parameter data packet can be called. This mapping relationship can be stored in the memory of the main control processor and obtained through information interaction between the artificial intelligence chip and the main control processor, such as the artificial intelligence chip sends the target task scheduling parameters and the target data storage instruction to the main control processor, and then receives the target data block scheduling configuration parameter data packet fed back by the main control processor; or, the above mapping relationship can also be established by the main control processor and then transmitted or copied to the memory of the artificial intelligence chip for storage, so that the artificial intelligence chip can find the above mapping relationship based on the target task scheduling parameters and the target data storage instruction, and obtain the corresponding target data block scheduling configuration parameter data packet. The present invention does not make specific limitations on this.

[0098] Based on the above Figure 1 In the task scheduling method shown in an exemplary embodiment, the following needs to be explained for the main control processor: The main control processor is used to execute the following steps for each computing task: first, the computing tasks are aligned in sequence based on the data block size, the thread block family size and the data block scheduling parameters to obtain updated computing tasks; further, the updated computing tasks are divided based on the data block size, the data block scheduling direction and the number of currently available computing units to obtain a data block scheduling configuration parameter data packet corresponding to the computing task; then, the data block scheduling configuration parameter data packet is stored in an immediate value mode or a register mode to generate a data storage instruction corresponding to the computing task.

[0099] Among them, the data block scheduling configuration parameter data packet may include but is not limited to the number of data blocks contained in each row, the number of data blocks contained in each column and the number of data blocks contained in the surface area after the computing tasks of the corresponding artificial intelligence operator are divided based on the currently available computing units, and the number of thread block clusters contained in each row and the number of thread blocks contained in each column under different scheduling directions of multiple thread blocks; the number of thread blocks is the same as the number of currently available computing units.

[0100] Specifically, for each computing task of different types of artificial intelligence operators, the computing task is first aligned using the data block size (such as the size of the tile), then aligned for the second time using the thread block family size (such as the size of the cluster), and finally aligned for the third time using the data block scheduling parameters (such as the Swizzle size) to obtain the updated computing task.

[0101] At this time, for the updated computing task, it is divided according to the data block size, data block scheduling direction and the number of currently available computing units. For example, if the computing task is a matrix multiplication computing task and the matrix multiplication computing task is A m×k ×B k×n =C m×n When , the corresponding segmented data blocks can be Figure 4 The dotted box in the C matrix of the matrix multiplication is the size of m, the size of k and the size of n; thus, the data block scheduling configuration parameter data packet corresponding to the computing task is obtained, and then all the data in the data block scheduling configuration parameter data packet are obtained in the register mode in an immediate manner to generate the data storage instruction corresponding to the computing task. All computing tasks are traversed in the above manner until the data block scheduling configuration parameter data packet and data storage instruction corresponding to each computing task are obtained.

[0102] Based on the above Figure 1 In the task scheduling method shown, in an exemplary embodiment, in step 130, the artificial intelligence chip executes a sub-computing task of processing multiple target data block coordinates corresponding to each target data block, and the specific process is implemented by the following steps.

[0103] When multiple target data block coordinates all belong to the current batch of target data block coordinates and do not exceed the target scale of the target computing task, each sub-computing task is processed; further, based on the processing completion mark, the next batch of target data block coordinates are re-determined in the multiple data blocks into which the target computing task is divided; then, all data block coordinates contained in the next batch of target data block coordinates are used as new target data block coordinates, and the above steps are repeated; until there is at least one invalid data block that exceeds the target scale among the multiple new target data block coordinates that are re-determined.

[0104] For details, please refer to Figure 2AAs shown in the target scheduling direction diagram, when 16 target data blocks need to be executed synchronously in each cycle processing, each batch of target data block coordinates includes 16 target data block coordinates. Figure 2A It can be seen from AlongN that 16 target data blocks are scheduled by row, wave0~wave5 are 6 cycles in which 16 target data block coordinates are scheduled by row in each cycle and none of them contain invalid data blocks exceeding the target size; Figure 2A In wave6, it means that in the 7th loop, the 16 target data block coordinates scheduled by row contain only 3 target data blocks, and the remaining 13 are invalid data blocks that exceed the target scale, that is, all 13 data blocks exceed the target scale and are illegal. At this time, after the 7th loop executes the 3 target data blocks, it can jump out of the loop and complete the calculation process of the target calculation task.

[0105] For example, refer to Figure 5 The second flowchart of the task scheduling method shown in FIG. Figure 5 As shown, when the main control processor is a central processing unit, the central processing unit can calculate the different data block scheduling configuration parameters after preprocessing of the target computing task according to the target scale of the target computing task, the data block size, the number of currently available computing units in the artificial intelligence chip and the target task scheduling parameters and the target data storage instructions, and then copy the different data block scheduling configuration parameters to the artificial intelligence chip in the form of a target data block scheduling configuration parameter data packet.

[0106] The AI ​​chip calculates the coordinates of each target data block that needs to be processed synchronously in each loop. Each target data block coordinate can be calculated based on the linear index of the corresponding thread block. The next target data block coordinate is calculated based on the updated linear index until multiple target data block coordinates are calculated and multiple sub-computing tasks are executed synchronously. Then, the coordinates of each target data block that needs to be processed synchronously in the next loop are calculated in the same way as above. Until the calculation process of the target computing task is completed.

[0107] The task scheduling device provided by the present invention is described below. The task scheduling device described below and the task scheduling method described above can be referred to each other.

[0108] Reference Figure 6 The structural diagram of the task scheduling device shown in FIG. Figure 6 As shown, the task scheduling device 600 is applied to an artificial intelligence chip that runs an artificial intelligence algorithm, and includes: a parameter acquisition unit 610 and a task scheduling unit 620.

[0109] The parameter acquisition unit 610 is used to respond to the task scheduling instruction and obtain the scheduling configuration parameters of different data blocks after preprocessing of the target computing task of the artificial intelligence operator; each data block scheduling configuration parameter is provided by the main control processor.

[0110] The task scheduling unit 620 is used to determine multiple target data block coordinates that match the number of currently available computing units based on the scheduling configuration parameters of each data block, and execute sub-computing tasks for processing the target data blocks corresponding to each of the multiple target data block coordinates.

[0111] Optionally, the task scheduling unit 620 is specifically used to execute the following steps for each thread block with the same number as the currently available computing units: determine the thread block family number of the thread block family based on the linear index of the thread block and the thread block family size of the thread block corresponding to the thread block; determine the scheduling area size corresponding to the thread block family based on the thread block family number and each data block scheduling configuration parameter; determine the target data block coordinates that need to be processed by the available computing unit corresponding to the thread block based on the scheduling area size and the position offset of the thread block in the corresponding thread block family.

[0112] Optionally, the task scheduling unit 620 is specifically configured to determine the thread block family size based on the row size of the thread block family and the column size of the thread block family; and determine the thread block family number based on the linear index and the thread block family size.

[0113] Optionally, the task scheduling unit 620 is specifically used to determine the row number of the thread block family based on the integer division result of the thread block family number and the number of thread block families contained in each row when each data block scheduling configuration parameter includes the number of thread block families contained in each row when multiple thread blocks are scheduled in a row direction; determine the column number of the thread block family based on the remainder operation result of the thread block family number and the number of thread block families contained in each row; determine the scheduling area size based on the row number and the column number; or, when each data block scheduling configuration parameter includes the number of thread block families contained in each column when multiple thread blocks are scheduled in a column direction, determine the column number of the thread block family based on the integer division result of the thread block family number and the number of thread block families contained in each column; determine the row number of the thread block family based on the remainder operation result of the thread block family number and the number of thread block families contained in each column; determine the scheduling area size based on the row number and the column number.

[0114] Optionally, the task scheduling unit 620 is specifically used to determine the row coordinates of the data blocks that need to be processed by the available computing units corresponding to the thread blocks based on the row size of the data blocks that need to be processed by the available computing units corresponding to the thread blocks, the row size of the thread block family and the row number of the scheduling region size, and the row offset of the thread blocks in the corresponding thread block family; determine the column coordinates of the data blocks that need to be processed by the available computing units corresponding to the thread blocks based on the column size of the data blocks that need to be processed by the available computing units corresponding to the thread blocks, the column size of the thread block family and the column number of the scheduling region size, and the column offset of the thread blocks in the corresponding thread block family; and determine the data block row coordinates and the data block column coordinates as the target data block coordinates that need to be processed by the available computing units corresponding to the thread blocks.

[0115] Optionally, the parameter acquisition unit 610 is specifically used to respond to the task scheduling instruction, obtain the target data block scheduling configuration parameter data packet based on the target task scheduling parameters and target data storage instructions carried in the task scheduling instruction, and the mapping relationship between the task scheduling parameters-data storage instructions-data block scheduling configuration parameter data packets, and the target data block scheduling configuration parameter data packets contain different data block scheduling configuration parameters; wherein the mapping relationship is established based on the different data block scheduling configuration parameter data packets and different data storage instructions determined by the main control processor after pre-processing the computing tasks of different types of artificial intelligence operators.

[0116] Optionally, the main control processor in the parameter acquisition unit 610 is used to execute the following steps for each computing task: align the computing tasks in sequence based on the data block size, thread block family size and data block scheduling parameters to obtain updated computing tasks; divide the updated computing tasks based on the data block size, data block scheduling direction and the number of currently available computing units to obtain a data block scheduling configuration parameter data packet corresponding to the computing task; store the data block scheduling configuration parameter data packet in immediate value mode or register mode to generate a data storage instruction corresponding to the computing task.

[0117] Optionally, the task scheduling unit 620 is specifically used to process each sub-computing task when multiple target data block coordinates all belong to the current batch of target data block coordinates and do not exceed the target scale of the target computing task; based on the processing completion mark, redetermine the next batch of target data block coordinates in the multiple data blocks into which the target computing task is divided; use all data block coordinates contained in the next batch of target data block coordinates as new target data block coordinates, and repeat the above steps; until there is at least one invalid data block that exceeds the target scale among the multiple new target data block coordinates that are redetermined.

[0118] Figure 7 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 7As shown, the electronic device may include: a main control processor (not shown in the figure) connected in the form of a heterogeneous framework, an artificial intelligence (AI) chip 710 running an artificial intelligence algorithm, a communication interface (Communications Interface) 720, a memory 730 and a communication bus 740, wherein the AI ​​chip 710, the communication interface 720, and the memory 730 communicate with each other through the communication bus 740. The AI ​​chip 710 can call the logic instructions in the memory 730 to execute the task scheduling method, which includes: in response to the task scheduling instruction, obtaining different data block scheduling configuration parameters after preprocessing of the target computing task of the artificial intelligence operator; each data block scheduling configuration parameter is provided by the main control processor; based on each data block scheduling configuration parameter, determining multiple target data block coordinates matching the number of currently available computing units, and executing sub-computing tasks of processing multiple target data block coordinates corresponding to the target data blocks; the main control processor is used to provide each data block scheduling configuration parameter to the AI ​​chip 710.

[0119] In addition, the logic instructions in the above-mentioned memory 730 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present invention can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0120] On the other hand, the present invention also provides a computer program product, which includes a computer program, and the computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the task scheduling method provided by the above methods, and the method includes: in response to a task scheduling instruction, obtaining different data block scheduling configuration parameters after preprocessing of the target computing task of the artificial intelligence operator; each data block scheduling configuration parameter is provided by a main control processor; based on each data block scheduling configuration parameter, determining multiple target data block coordinates that match the number of currently available computing units, and executing sub-computing tasks of processing the target data blocks corresponding to each of the multiple target data block coordinates.

[0121] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the task scheduling method provided by the above-mentioned methods, the method comprising: in response to a task scheduling instruction, obtaining different data block scheduling configuration parameters after preprocessing of the target computing task of the artificial intelligence operator; each data block scheduling configuration parameter is provided by a main control processor; based on each data block scheduling configuration parameter, determining multiple target data block coordinates that match the number of currently available computing units, and executing sub-computing tasks of processing the target data blocks corresponding to each of the multiple target data block coordinates.

[0122] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0123] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0124] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A task scheduling method, characterized in that: An artificial intelligence chip for running an artificial intelligence algorithm, the method comprising: In response to the task scheduling instruction, different data block scheduling configuration parameters after preprocessing of the target computing task of the artificial intelligence operator are obtained; each of the data block scheduling configuration parameters is provided by the main control processor; Based on the data block scheduling configuration parameters, multiple target data block coordinates that match the number of currently available computing units are determined, and sub-computing tasks for processing the target data blocks corresponding to each of the multiple target data block coordinates are executed.

2. The task scheduling method according to claim 1, characterized in that: The step of determining a plurality of target data block coordinates that match the number of currently available computing units based on each of the data block scheduling configuration parameters comprises: The following steps are performed for each thread block having the same number as the currently available computing units: Determine a thread block family number of the thread block family based on the linear index of the thread block and the thread block family size of the thread block family corresponding to the thread block; Determine the scheduling region size corresponding to the thread block family based on the thread block family number and each of the data block scheduling configuration parameters; The target data block coordinates required to be processed by the thread block corresponding to the available computing unit are determined based on the scheduling region size and the position offset of the thread block in the corresponding thread block cluster.

3. The task scheduling method according to claim 2, characterized in that: The determining the thread block family number of the thread block family based on the linear index of the thread block and the thread block family size of the thread block family corresponding to the thread block includes: Determining a size of the thread block cluster based on a row size of the thread block cluster and a column size of the thread block cluster; The thread block cluster number is determined based on the linear index and the thread block cluster size.

4. The task scheduling method according to claim 2, characterized in that: The determining, based on the thread block family number and each of the data block scheduling configuration parameters, a scheduling region size corresponding to the thread block family includes: When each of the data block scheduling configuration parameters includes the number of thread block clusters contained in each row when the plurality of thread blocks are scheduled in a row direction, Determine the row number where the thread block family is located based on the integer division result of the thread block family number and the number of thread block families contained in each row; Determine the column number where the thread block family is located based on a modulo operation result of the thread block family number and the number of thread block families contained in each row; Determining the scheduling region size based on the row number and the column number; Alternatively, when each of the data block scheduling configuration parameters includes the number of thread block clusters contained in each column when the plurality of thread blocks are scheduled in a column direction, Determine the column number where the thread block family is located based on the integer division result of the thread block family number and the number of thread block families contained in each column; Determine the row number where the thread block family is located based on a modulo operation result of the thread block family number and the number of thread block families contained in each column; The scheduling region size is determined based on the row number and the column number.

5. The task scheduling method according to claim 2, characterized in that: The determining, based on the scheduling region size and the position offset of the thread block in the corresponding thread block cluster, the target data block coordinates required to be processed by the thread block corresponding to the available computing unit includes: Determine the row coordinates of the data blocks that the thread block needs to process corresponding to the available computing unit based on the row size of the data blocks that the thread block needs to process corresponding to the available computing unit, the row size of the thread block family, the row number of the scheduling region size, and the row offset of the thread block in the corresponding thread block family; Determine the data block column coordinates that the thread block needs to process corresponding to the available computing unit based on the data block column size that the thread block needs to process corresponding to the available computing unit, the column size of the thread block family, the column number of the scheduling region size, and the column offset of the thread block in the corresponding thread block family; The data block row coordinates and the data block column coordinates are determined as the target data block coordinates that the thread block needs to process corresponding to the available computing unit.

6. The task scheduling method according to any one of claims 1 to 5, characterized in that: The step of obtaining, in response to the task scheduling instruction, different data block scheduling configuration parameters after preprocessing of the target computing task of the artificial intelligence operator includes: In response to the task scheduling instruction, based on the target task scheduling parameters and the target data storage instruction carried in the task scheduling instruction, and the mapping relationship between the task scheduling parameters, the data storage instruction, and the data block scheduling configuration parameter data packet, a target data block scheduling configuration parameter data packet is obtained, wherein the target data block scheduling configuration parameter data packet contains the different data block scheduling configuration parameters; The mapping relationship is established based on different data block scheduling configuration parameter data packets and different data storage instructions determined by the main control processor after preprocessing the computing tasks of different types of artificial intelligence operators.

7. The task scheduling method according to claim 6, characterized in that: The main control processor is used to perform the following steps for each computing task: Aligning the computing tasks in sequence based on the data block size, the thread block family size, and the data block scheduling parameters to obtain updated computing tasks; Dividing the updated computing task based on the data block size, the data block scheduling direction and the number of currently available computing units to obtain a data block scheduling configuration parameter data packet corresponding to the computing task; The data block scheduling configuration parameter data packet is stored in an immediate value manner or a register manner, and a data storage instruction corresponding to the computing task is generated.

8. The task scheduling method according to any one of claims 1 to 5, characterized in that: The executing and processing the sub-computing tasks of the target data blocks corresponding to the coordinates of the plurality of target data blocks respectively comprises: When the coordinates of the plurality of target data blocks all belong to the coordinates of the target data blocks of the current batch and do not exceed the target scale of the target computing task, processing each of the sub-computing tasks; Based on the processing completion mark, re-determine the coordinates of the next batch of target data blocks in the multiple data blocks into which the target computing task is divided; All data block coordinates contained in the next batch of target data block coordinates are used as new target data block coordinates, and the above steps are repeated until at least one invalid data block exceeding the target size exists in the newly determined multiple target data block coordinates.

9. A task scheduling device, characterized in that: An artificial intelligence chip for running an artificial intelligence algorithm, the device comprising: A parameter acquisition unit, used to obtain different data block scheduling configuration parameters after preprocessing of the target computing task of the artificial intelligence operator in response to the task scheduling instruction; each of the data block scheduling configuration parameters is provided by the main control processor; The task scheduling unit is used to determine multiple target data block coordinates that match the number of currently available computing units based on the data block scheduling configuration parameters, and execute sub-computing tasks for processing the target data blocks corresponding to the multiple target data block coordinates.

10. An electronic device, characterized in that: It includes a main control processor and an AI chip that runs an AI algorithm connected in a heterogeneous framework; The artificial intelligence chip is used to respond to the task scheduling instruction, obtain different data block scheduling configuration parameters after preprocessing of the target computing task of the artificial intelligence operator; based on each of the data block scheduling configuration parameters, determine multiple target data block coordinates that match the number of currently available computing units, and execute sub-computing tasks for processing the target data blocks corresponding to each of the multiple target data block coordinates; The main control processor is used to provide the artificial intelligence chip with scheduling configuration parameters for each of the data blocks.

11. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the task scheduling method according to any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Task processing method and device and related product

    CN111381946A

  • Calculation task scheduling method and system, electronic equipment and storage medium

    CN117519922A

  • Operator execution method and device, equipment and storage medium

    CN117808048A

  • Task scheduling method and device based on multiple operators, computer equipment and storage medium

    CN118550674A

  • Configuring thread scheduling on a multi-threaded data processing apparatus

    US20150160970A1

Cited By

  • Method for segmenting tasks, computing device, medium and program product

    CN121187809A

  • Methods, computing devices, media, and program products for a segmentation task

    CN121187809B

  • Method for issuing tasks about kernel functions, artificial intelligence chip, computing device, medium and program product

    CN121210146A

  • Task scheduling method and system, chip and program product

    CN122489249A

  • Task scheduling method, system, chip and program product

    CN122489249B