Scheduling method and device of asynchronous task, equipment, storage medium and program product

CN122261774BActive Publication Date: 2026-08-18INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202610746448.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-05-27
Publication Date
2026-08-18
Estimated Expiration
2046-05-27

AI Technical Summary

Technical Problem

[0005]本申请提供了一种异步任务的调度方法、装置、设备、存储介质及程序产品,以至少解决相关技术中服务器集群的资源利用率较低的问题

Benefits of technology

[0017]This application provides a scheduling method, apparatus, device, storage medium, and program product for asynchronous tasks. The method includes: in response to receiving a processing request for a computing task, generating task queue information corresponding to the computing task, the task queue information including task parameters corresponding to at least one type of asynchronous task; obtaining a first semaphore and a second semaphore corresponding to at least one type of asynchronous task; wherein the first semaphore is used to indicate the amount of asynchronous tasks already processed by the task processor, and the second semaphore is used to indicate the amount of asynchronous tasks submitted by the computing processor to be processed; determining whether the first semaphore and the second semaphore corresponding to the asynchronous task of that type satisfy a preset condition variable, and if so, waking up the asynchronous task thread, and reading the task parameters corresponding to the asynchronous task of that type from the task queue information through the asynchronous task thread, and executing the asynchronous task of that type according to the task parameters. In this embodiment, by waking up the asynchronous task thread through a semaphore mechanism, busy waiting of the asynchronous task thread is avoided. This means that the asynchronous task thread does not need to be in a working state all the time, reducing the server resources occupied by the asynchronous task thread and thus improving the resource utilization of the server cluster. Furthermore, waking up the asynchronous task thread through the first and second semaphores can balance the amount of tasks processed by the task processor and the amount of tasks submitted by the computing processor, ensuring the consistency of the task states of the task processor and the computing processor, reducing the waiting time of the computing processor, and further improving the resource utilization of the server cluster.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122261774B_ABST
    Figure CN122261774B_ABST
Patent Text Reader

Abstract

The application discloses a scheduling method and device of asynchronous tasks, equipment, a storage medium and a program product, and relates to the technical field of servers. The method comprises the following steps: in response to receiving a processing request of a calculation task, generating task queue information corresponding to the calculation task; acquiring a first semaphore and a second semaphore corresponding to at least one type of asynchronous task, wherein the first semaphore is used for indicating the task quantity of the asynchronous tasks processed by a task processor, and the second semaphore is used for indicating the task quantity of the asynchronous tasks to be processed submitted by a calculation processor; determining whether the first semaphore and the second semaphore corresponding to the type of asynchronous task satisfy a preset condition variable, if yes, waking up an asynchronous task thread, reading task parameters corresponding to the type of asynchronous task from the task queue information through the asynchronous task thread, and executing the type of asynchronous task according to the task parameters. The method can improve the resource utilization rate of a server cluster.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of server technology, and in particular to a method, apparatus, device, storage medium, and program product for scheduling asynchronous tasks. Background Technology

[0002] In scenarios involving the training and inference of artificial intelligence models, server clusters comprise computing processors (e.g., graphics processing units) and task processors. The computing processors handle computational tasks, while the task processors process asynchronous tasks submitted by the computing processors.

[0003] In related technologies, when a computing processor is processing a computing task, the task processor can call an asynchronous task thread to query whether each computing processor has an asynchronous task that needs to be transmitted. If so, the asynchronous task is processed through the asynchronous task thread.

[0004] However, the scheduling methods for asynchronous tasks in related technologies require asynchronous task threads to query each computing processor in real time whether there are asynchronous tasks that need to be transmitted. Even when there are no asynchronous tasks, the asynchronous task threads also need to be in a working state, which leads to low resource utilization of the server cluster. Summary of the Invention

[0005] This application provides a method, apparatus, device, storage medium, and program product for scheduling asynchronous tasks, in order to at least solve the problem of low resource utilization in server clusters in related technologies.

[0006] On the one hand, this application provides a method for scheduling asynchronous tasks, including:

[0007] In response to receiving a processing request for a computing task, task queue information corresponding to the computing task is generated. The task queue information includes task parameters corresponding to at least one type of asynchronous task.

[0008] Obtain a first semaphore and a second semaphore corresponding to each of at least one type of asynchronous task; wherein the first semaphore is used to indicate the amount of asynchronous tasks that the task processor has processed, and the second semaphore is used to indicate the amount of asynchronous tasks that the computation processor has submitted to be processed.

[0009] Determine whether the first and second semaphores corresponding to the asynchronous task of a certain type meet the preset condition variables. If they do, wake up the asynchronous task thread and read the task parameters corresponding to the asynchronous task of that type from the task queue information. Then, execute the asynchronous task of that type according to the task parameters.

[0010] On the other hand, this application provides a scheduling apparatus for asynchronous tasks, comprising:

[0011] The generation module is used to generate task queue information corresponding to the received computing task in response to the processing request of the computing task. The task queue information includes task parameters corresponding to at least one type of asynchronous task.

[0012] An acquisition module is used to acquire a first semaphore and a second semaphore corresponding to at least one type of asynchronous task; wherein the first semaphore is used to indicate the amount of asynchronous tasks that the task processor has processed, and the second semaphore is used to indicate the amount of asynchronous tasks that the computing processor has submitted to be processed.

[0013] The scheduling module is used to determine whether the first and second semaphores corresponding to the asynchronous task of a certain type meet the preset condition variables. If they do, the asynchronous task thread is woken up, and the asynchronous task thread reads the task parameters corresponding to the asynchronous task of a certain type from the task queue information and executes the asynchronous task of that type according to the task parameters.

[0014] This application also provides an electronic device, including: a memory for storing a computer program; and a processor for implementing the scheduling method of any of the above-described asynchronous tasks when executing the computer program.

[0015] This application also provides a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of any of the above-described asynchronous task scheduling methods.

[0016] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the above-described asynchronous task scheduling methods.

[0017] This application provides a scheduling method, apparatus, device, storage medium, and program product for asynchronous tasks. The method includes: in response to receiving a processing request for a computing task, generating task queue information corresponding to the computing task, the task queue information including task parameters corresponding to at least one type of asynchronous task; obtaining a first semaphore and a second semaphore corresponding to at least one type of asynchronous task; wherein the first semaphore is used to indicate the amount of asynchronous tasks already processed by the task processor, and the second semaphore is used to indicate the amount of asynchronous tasks submitted by the computing processor to be processed; determining whether the first semaphore and the second semaphore corresponding to the asynchronous task of that type satisfy a preset condition variable, and if so, waking up the asynchronous task thread, and reading the task parameters corresponding to the asynchronous task of that type from the task queue information through the asynchronous task thread, and executing the asynchronous task of that type according to the task parameters. In this embodiment, by waking up the asynchronous task thread through a semaphore mechanism, busy waiting of the asynchronous task thread is avoided. This means that the asynchronous task thread does not need to be in a working state all the time, reducing the server resources occupied by the asynchronous task thread and thus improving the resource utilization of the server cluster. Furthermore, waking up the asynchronous task thread through the first and second semaphores can balance the amount of tasks processed by the task processor and the amount of tasks submitted by the computing processor, ensuring the consistency of the task states of the task processor and the computing processor, reducing the waiting time of the computing processor, and further improving the resource utilization of the server cluster. Attached Figure Description

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

[0019] Figure 1 A schematic diagram illustrating an application scenario of the asynchronous task scheduling method provided in this application embodiment;

[0020] Figure 2 The flowchart of the asynchronous task scheduling method provided in the embodiments of this application Figure 1 ;

[0021] Figure 3 A schematic diagram of the graph task queue information provided in the embodiments of this application. Figure 1 ;

[0022] Figure 4 A schematic diagram of the graph callback mapping table provided in the embodiments of this application. Figure 1 ;

[0023] Figure 5 A schematic diagram of the asynchronous task scheduling method provided in the embodiments of this application. Figure 1 ;

[0024] Figure 6 A schematic diagram of the asynchronous task scheduling method provided in the embodiments of this application. Figure 2 ;

[0025] Figure 7 A schematic diagram of the structure of the asynchronous task scheduling device provided in the embodiments of this application;

[0026] Figure 8 A schematic diagram of the structure of the electronic device provided in this application. Detailed Implementation

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

[0028] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.

[0029] In scenarios involving the training and inference of artificial intelligence models, server clusters consist of graphics processing units (GPUs) and task processors. GPUs handle computational tasks, while task processors process asynchronous tasks submitted by the GPUs. The asynchronous task scheduling between the GPUs and task processors becomes a performance bottleneck for the server cluster.

[0030] In related technologies, when a computing processor is handling a computing task, the task processor can call an asynchronous task thread to query whether there are any asynchronous tasks that need to be transmitted to each computing processor. If so, the asynchronous task thread will process the asynchronous task. However, because the asynchronous task thread needs to query each computing processor in real time to see if there are any asynchronous tasks that need to be transmitted, it also needs to be in a working state even when there are no asynchronous tasks, which leads to low resource utilization of the server cluster.

[0031] Therefore, how to reasonably schedule asynchronous task threads to improve the resource utilization of server clusters is a technical problem that urgently needs to be solved.

[0032] To address the aforementioned technical problems, this application proposes an asynchronous task scheduler, optionally, such as Figure 1 As shown, the application layer initiates a computation task processing request by calling the computation task API (Application Programming Interface). Upon receiving the computation task processing request, the task processor calls the asynchronous task scheduler to collect asynchronous tasks and saves them to a queue. The computation processor (e.g., a graphics processing unit) begins executing a subtask of the computation task, notifying the asynchronous task scheduler of the task processor that an asynchronous task is pending execution by submitting a semaphore for the asynchronous task. The asynchronous task scheduler wakes up the asynchronous worker thread based on the semaphore state. The task processor executes the asynchronous task while the computation processor is processing the computation task, achieving maximum overlap between task execution by the task processor and the computation processor.

[0033] Because this asynchronous task scheduler can wake up asynchronous task threads using a first and a second semaphore, it avoids busy waiting by these threads, reducing the server resources they consume. Furthermore, waking up asynchronous task threads with the first and second semaphores balances the amount of tasks processed by the task processors and the amount of tasks submitted by the computing processors, ensuring consistency in task states between the task processors and computing processors, reducing waiting time for the computing processors, and maximizing overlap between tasks, thereby further improving the resource utilization of the server cluster. The asynchronous task scheduler can schedule different types of asynchronous tasks based on semaphores. The scheduler is initialized at system startup, and the task executors enter an infinite loop, but instead of checking for arriving tasks in real time, it is triggered by a condition variable. When there are no tasks, the task executors sleep.

[0034] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0035] The specific application environment architecture or specific hardware architecture on which the execution of the asynchronous task scheduling method depends is described here.

[0036] Figure 2 The flowchart of the asynchronous task scheduling method provided in the embodiments of this application Figure 1 The execution entity of the scheduling method for this asynchronous task can be a server. For example... Figure 2 As shown, the scheduling method for this asynchronous task includes:

[0037] S201. In response to receiving a processing request for a computing task, generate task queue information corresponding to the computing task. The task queue information includes task parameters corresponding to at least one type of asynchronous task.

[0038] In this embodiment, the asynchronous task can be any type of asynchronous task submitted by the computing processor. Optionally, the computing processor can be a graphics processor. For example, the asynchronous task can be an asynchronous communication task submitted by the graphics processor.

[0039] In some embodiments, communication tasks can be offloaded from a computing processor (e.g., a graphics processing unit) to a task processor (e.g., a central processing unit). This allows the computing processor to focus on processing computational tasks. In this case, the task processor can invoke an asynchronous task scheduler to collect task parameters corresponding to at least one type of asynchronous task and save these parameters to a task queue to generate task queue information corresponding to the computational tasks.

[0040] Optionally, the asynchronous task scheduler can manage asynchronous tasks through a separate worker thread, supporting both graph capture and non-graph capture modes. Accordingly, in response to receiving a processing request for a computation task, task queue information corresponding to the computation task is generated, including: in response to receiving a processing request for a computation task, obtaining the task mode identifier corresponding to the computation task and the task parameters corresponding to at least one type of asynchronous task included in the computation task from the task information carried in the processing request; and generating the task queue information corresponding to the computation task based on the task mode identifier and the task parameters corresponding to at least one type of asynchronous task.

[0041] The task mode identifier is used to indicate the task mode of the computation task, thereby generating task queue information corresponding to different task modes.

[0042] In some embodiments, the task mode includes a graph capture mode and a non-graph capture mode. In graph capture mode, task parameters are acquired and graph task queue information is saved during graph capture. During graph playback, an asynchronous task thread is woken up and task parameters are read from the graph task queue information. In non-graph capture mode, a task is added after task acquisition is completed, thereby triggering a worker thread.

[0043] Optionally, generating task queue information corresponding to the computation task based on the task mode identifier and the task parameters corresponding to at least one type of asynchronous task includes: if the task mode identifier is used to indicate that the computation task is in graph capture mode, then obtaining the graph capture identifier corresponding to the computation task from the task information carried in the processing request, and generating graph task queue information corresponding to the computation task based on the graph capture identifier and the task parameters corresponding to at least one type of asynchronous task; if the task mode identifier is used to indicate that the computation task is in non-graph capture mode, then generating non-graph task queue information corresponding to the computation task based on the task parameters corresponding to at least one type of asynchronous task.

[0044] In this embodiment, since graph task queue information is generated in graph capture mode and non-graph task queue information is generated in non-graph capture mode, asynchronous task acquisition in both graph capture mode and non-graph capture mode is realized, thus improving the adaptability of the task scheduling method.

[0045] In some embodiments, if it is a graph capture mode, it is determined whether the computation task is a new graph task; if the computation task is a new graph task, a new task queue member is created and added to the task queue; accordingly, based on the graph capture identifier and the task parameters corresponding to at least one type of asynchronous task, graph task queue information corresponding to the computation task is generated, including: determining whether the computation task is a new graph task based on the graph capture identifier; wherein a new graph task is used to indicate that the graph task queue information does not include the task parameters corresponding to at least one type of asynchronous task; if the computation task is a new graph task, the graph task identifier corresponding to at least one type of asynchronous task is determined, and a correspondence between the graph task identifier and the task parameters is generated based on the graph task identifier corresponding to at least one type of asynchronous task and the task parameters corresponding to at least one type of asynchronous task, and the correspondence is added to the graph task queue information.

[0046] The graph task identifier is used to distinguish different types of asynchronous tasks.

[0047] In some embodiments, an asynchronous task of a certain type can be invoked multiple times, with different task parameters for each invocation, including one or more subtask parameters.

[0048] Optionally, the graph task queue consists of a graph identifier and task parameters. A graph called at least once contains at least one set of parameters; when called multiple times, the graph identifier contains multiple sets of task parameters. Task parameters are a union data structure. Asynchronous tasks include various categories, such as dispatch and recycling, and these asynchronous tasks share this data structure.

[0049] For example, such as Figure 3As shown, the task parameters include multiple subtask parameters. By using graph capture identifiers, it is determined that the computation task is a new graph task. The graph type identifiers corresponding to at least one type of asynchronous task are identified, including: a first graph type identifier, a second graph type identifier, ..., the m-th graph type identifier. A correspondence is established between the first graph type identifier and multiple subtask parameters (e.g., first subtask parameter, second subtask parameter, and third subtask parameter), and this correspondence is added to the graph task queue information. Similarly, a correspondence is established between the second graph type identifier and multiple subtask parameters, and this correspondence is added to the graph task queue information. Finally, a correspondence is established between the m-th graph type identifier and multiple subtask parameters, and this correspondence is added to the graph task queue information.

[0050] In this embodiment, when the computation task is a new graph task, a correspondence between the graph task identifier and the task parameters is generated and the correspondence is added to the graph task queue information. The task parameters are stored through the graph task queue information, which realizes the delayed execution of asynchronous tasks and ensures the consistency of task execution between the task processor and the computation processor, thereby reducing the waiting time of the computation processor.

[0051] In some embodiments, if the computation task is a new graph task, a graph callback function corresponding to the computation task is registered. The graph callback function is used to call the task parameters corresponding to at least one type of asynchronous task in the computation task through the graph callback mapping table during graph playback.

[0052] In this embodiment, when the computation task is a new graph task, the graph callback function corresponding to the computation task is registered. In this way, during graph playback, the task parameters corresponding to the asynchronous tasks in the graph task queue can be called through the graph callback function, realizing the capture and replay of computation tasks, ensuring the efficient reuse of task parameters during graph playback, reducing the waiting time of the computing processor, and thus further improving the resource utilization of the server cluster.

[0053] In some embodiments, if it is not a new graph, the number of tasks for that graph is added to the existing task count. Accordingly, the method further includes: if the computation task is not a new graph task, obtaining the number of pending tasks corresponding to at least one type of asynchronous task from the task information carried in the processing request, and adding the number of pending tasks to the second semaphore corresponding to the type of asynchronous task to obtain the updated second semaphore.

[0054] In this embodiment, it can be determined whether a computation task is a new graph task by querying the graph callback mapping table. Accordingly, determining whether a computation task is a new graph task using a graph capture identifier includes: querying whether the graph capture identifier already exists in the graph callback mapping table; wherein the graph callback mapping table stores the mapping relationship between the graph capture identifier, the graph task identifier corresponding to the asynchronous task of a certain type, and the second semaphore corresponding to the asynchronous task of a certain type; if it exists, it is determined that the computation task is not a new graph task; if it does not exist, it is determined that the computation task is a new graph task.

[0055] In some embodiments, if the computation task is a new graph task, the mapping data corresponding to the computation task is generated and added to the graph callback mapping table. Accordingly, the method further includes: if the computation task is a new graph task, obtaining the amount of pending tasks submitted by the computation processor from the task information carried in the processing request, determining the amount of pending tasks as a second semaphore corresponding to the type of asynchronous task; establishing a mapping relationship between the graph capture identifier, the graph task identifier corresponding to the type of asynchronous task, and the second semaphore corresponding to the type of asynchronous task, and storing the mapping relationship in the graph callback mapping table.

[0056] For example, such as Figure 4 As shown, the computation task is determined to be a new graph task by using the first graph capture identifier, and the amount of tasks to be processed is determined as the second semaphore corresponding to the asynchronous task of the type. A mapping relationship is established between the first graph capture identifier, the graph task identifiers corresponding to multiple types of asynchronous tasks (e.g., the first graph type identifier, the second graph type identifier, ..., the m-th graph type identifier), and the second semaphores corresponding to multiple types of asynchronous tasks, and the mapping relationship is stored in the graph callback mapping table.

[0057] In this embodiment, when the computation task is a new graph task, a mapping relationship is established between the graph capture identifier, the graph task identifier corresponding to the type of asynchronous task, and the second semaphore corresponding to the type of asynchronous task. The mapping relationship is stored in the graph callback mapping table. In this way, when the computation task is received again, the task parameters of the corresponding type of asynchronous task can be read from the existing graph task queue information without regenerating the graph task queue information corresponding to the computation task, thus improving the processing efficiency of asynchronous tasks.

[0058] In some embodiments, if the computation task is in non-graph capture mode, the task counter is directly incremented and the task parameters are added to the non-graph task queue.

[0059] Optionally, generating non-graph task queue information corresponding to the computation task based on the task parameters corresponding to at least one type of asynchronous task includes: obtaining the amount of pending tasks submitted by the computation processor from the task information, appending the amount of pending tasks to the second semaphore corresponding to the type of asynchronous task, and adding the task parameters corresponding to at least one type of asynchronous task to the non-graph task queue information to generate non-graph task queue information corresponding to the computation task.

[0060] In this embodiment of the application, if the computation task is in non-graph capture mode, then there is no graph task identifier involved. The task parameters can be added to the non-graph task queue during the task acquisition stage and read when the task is executed. Furthermore, the computation task in non-graph capture mode does not involve graph replay or repeated execution. When the task parameters are called, they can be executed in the order in the non-graph task queue.

[0061] For example, such as Figure 5 As shown, the flow of asynchronous tasks in both graph capture mode and non-graph capture mode can include:

[0062] (1) Obtain the input parameters passed in by the upper layer application when it is called, including the graph capture identifier and the task parameters corresponding to at least one type of asynchronous task in the computation task.

[0063] (2) If it is graph capture mode, query the graph callback mapping table to see if the graph capture identifier is included, in order to determine whether the computation task is a new graph task: if it is a new graph task, generate new mapping data and insert it into the graph callback mapping table, and register the new graph callback function into the CUDA callback function so that the graph can be called during graph playback; if it is not a new graph task, query the graph callback identifier in the graph callback mapping table and add the number of tasks for the graph to the existing task count; if it is a new graph task, create a new task queue member and add it to the task queue; if it is not a new graph task, append the task to the existing task with the graph identifier.

[0064] (3) If it is not graph capture mode, the task counter is incremented directly and the task is added to the non-graph task queue.

[0065] (4) Return the tail semaphore of the corresponding mode so that the compute processor can issue asynchronous communication tasks.

[0066] S202. Obtain a first semaphore and a second semaphore corresponding to at least one type of asynchronous task; wherein the first semaphore is used to indicate the amount of asynchronous tasks that the task processor has processed, and the second semaphore is used to indicate the amount of asynchronous tasks that the computing processor has submitted to be processed.

[0067] In some embodiments, based on task priority, a first semaphore and a second semaphore corresponding to at least one type of asynchronous task are obtained, and it is detected whether the first semaphore and the second semaphore satisfy a preset condition variable.

[0068] Optionally, obtaining the first semaphore and the second semaphore corresponding to each of at least one type of asynchronous task includes: obtaining the task priority corresponding to each of at least one type of asynchronous task; determining the execution order of at least one type of asynchronous task according to the task priority corresponding to each of at least one type of asynchronous task; and obtaining the first semaphore and the second semaphore corresponding to the asynchronous task of each type according to the order in which the at least one type of asynchronous task is executed.

[0069] The first and second semaphores can form a semaphore pair, corresponding to a type of asynchronous task. For example, a semaphore pair consists of two 64-bit unsigned integers. After completing a computational task, the computing processor (e.g., a graphics processing unit) needs to call the task processor to execute the asynchronous task. At this time, the asynchronous task quantity is accumulated in the tail semaphore pool to the second semaphore corresponding to that type of asynchronous task, thereby increasing the task quantity of the corresponding type of asynchronous task to be executed.

[0070] For example, such as Figure 6 As shown, the corresponding semaphores in the head semaphore pool and tail semaphore pool can be continuously polled according to the priority of the asynchronous task. When the two are not equal, it means that the task has not been completed. The host will then call the corresponding type of asynchronous task and add the first semaphore of the asynchronous task of that type in the head semaphore pool.

[0071] In some embodiments, obtaining the first semaphore and the second semaphore corresponding to the asynchronous task of the type includes: obtaining the task identifier corresponding to the asynchronous task of the type; obtaining the first semaphore corresponding to the asynchronous task of the type from the host-side semaphore pool according to the task identifier; and obtaining the second semaphore corresponding to the asynchronous task of the type from the device-side semaphore pool according to the task identifier; wherein the host-side semaphore pool is used to store the correspondence between the task identifier and the first semaphore, and the device-side semaphore pool is used to store the correspondence between the task identifier and the second semaphore.

[0072] Optionally, the method further includes: in response to reading the task parameters corresponding to the asynchronous task of the type from the task queue information through the asynchronous task thread, incrementing the first semaphore corresponding to the asynchronous task of the type in the host-side semaphore pool by 1 to obtain the updated first semaphore; and in response to executing the asynchronous task of the type according to the task parameters, decrementing the second semaphore corresponding to the asynchronous task of the type in the device-side semaphore pool by 1 to obtain the updated second semaphore.

[0073] It's important to note that asynchronous tasks and computational tasks have a sequential dependency. The computational task is the data producer, and the asynchronous task is the data consumer. Therefore, before an asynchronous task can begin, it must wait for the computational task to complete. After the computational task completes, the tail semaphore (i.e., the second semaphore) of the asynchronous task is incremented by 1, making the head semaphore value less than the tail semaphore. At this point, the task processor acquires this semaphore, stops waiting, and begins reading from the task queue and executing the asynchronous task. When reading the task parameters of the asynchronous task, the head semaphore (i.e., the first semaphore) of that asynchronous task is incremented by 1. After the asynchronous task completes, the task counter (used to track the second semaphore of the asynchronous task) corresponding to the asynchronous task is decremented by 1; if the task counter is cleared, the asynchronous task thread is switched to a sleep state.

[0074] In this embodiment of the application, by updating the first semaphore and the second semaphore, the dependency relationship between multiple types of asynchronous tasks is maintained, thereby improving the execution efficiency of multiple types of asynchronous tasks.

[0075] In some embodiments, the method further includes: determining whether the updated first semaphore and the updated second semaphore satisfy a preset condition variable; if they satisfy the condition variable, then continuing to read the task parameters corresponding to the asynchronous task of the type from the task queue information through the asynchronous task thread, and executing the asynchronous task of the type according to the task parameters; if they do not satisfy the condition variable, then switching the asynchronous task thread to a sleep state.

[0076] Optionally, the asynchronous task thread can obtain the status of the asynchronous scheduler and the number of scheduled tasks; if there are no scheduled tasks and the asynchronous scheduler is in a working state, the asynchronous task thread is switched to a dormant state; or, if the task scheduler is released and the stop flag is true, the asynchronous task thread is switched to a dormant state.

[0077] In this embodiment of the application, if the first semaphore and the second semaphore do not meet the preset condition variables, the asynchronous task thread is switched to a sleep state, thereby avoiding busy waiting of the asynchronous task thread and reducing the server resources occupied by the asynchronous task thread.

[0078] In some embodiments, the working state of the asynchronous task thread can be adjusted according to the total number of tasks corresponding to the asynchronous task thread. Accordingly, the method further includes: determining the total number of tasks corresponding to the asynchronous task thread based on the updated second semaphore corresponding to at least one type of asynchronous task; if the total number of tasks is less than or equal to a first preset value, then switching the asynchronous task thread to a sleep state.

[0079] In this embodiment, the value of the first preset value is not specifically limited. Optionally, the first preset value can be 0.

[0080] S203. Determine whether the first and second semaphores corresponding to the asynchronous task of the type meet the preset condition variables. If they do, wake up the asynchronous task thread and read the task parameters corresponding to the asynchronous task of the type from the task queue information through the asynchronous task thread, and execute the asynchronous task of the type according to the task parameters.

[0081] In some embodiments, such as Figure 6 As shown, determining whether the first and second semaphores corresponding to the asynchronous task of a certain type satisfy the preset condition variables includes: if the first semaphore corresponding to the asynchronous task of a certain type is less than the second semaphore, then the first and second semaphores corresponding to the asynchronous task of a certain type satisfy the preset condition variables; if the first semaphore corresponding to the asynchronous task of a certain type is equal to the second semaphore, then the first and second semaphores corresponding to the asynchronous task of a certain type do not satisfy the preset condition variables.

[0082] In this embodiment, by triggering the execution of asynchronous tasks through the condition variables corresponding to the first and second semaphores, the dependency relationships between multiple types of asynchronous tasks are maintained, improving the execution efficiency of multiple types of asynchronous tasks. Furthermore, by waking up asynchronous task threads through the first and second semaphores, the amount of tasks processed by the task processor and the amount of tasks submitted by the computing processor can be balanced, ensuring the consistency of task states between the task processor and the computing processor, reducing the waiting time of the computing processor, and thus further improving the resource utilization of the server cluster.

[0083] In some embodiments, in order to ensure that the same stored task parameters can be used multiple times without duplicate allocation and executed sequentially in a loop to support unlimited replay of the computation task, this application designs a circular queue indexing mechanism.

[0084] Optionally, the asynchronous task thread reads the task parameters corresponding to the asynchronous task of the type from the task queue information, and executes the asynchronous task of the type according to the task parameters, including: obtaining the number of multiple subtask parameters included in the task parameters; reading the target subtask parameter corresponding to this asynchronous task from the multiple subtask parameters included in the task parameters according to the first semaphore and the number; and executing the asynchronous task of the type according to the target subtask parameter.

[0085] In this embodiment of the application, the circular queue indexing mechanism can ensure that the same task parameter in the task queue information can be used multiple times and executed sequentially in a loop, realizing unlimited replay of the computing task, thus improving the processing efficiency of the computing task.

[0086] Optionally, based on the first semaphore and the quantity, the target subtask parameter corresponding to this asynchronous task is obtained from multiple subtask parameters included in the task parameters, including: performing a modulo operation on the first semaphore with the quantity as the modulus to obtain the target index value corresponding to the target subtask parameter; and obtaining the target subtask parameter corresponding to the target index value from the correspondence between the index value and multiple subtask parameters based on the target index value.

[0087] For example, suppose the task vector size of a graph is 3, meaning the total number of task parameters is 3. During task execution, task parameters are continuously read from the task queue based on the calculated index values. This design mechanism also needs to be used in conjunction with a graph callback function registration and callback invocation mechanism to achieve the effect of caching tasks during graph capture and reusing them during graph playback.

[0088] Optionally, the total number of queue task parameters is N, and head is the count of processed tasks (first semaphore). The index value is calculated using the formula: idx (index value) = head % N (modulo operation); the index value range is: 0 ≤ idx < N, and it cycles automatically.

[0089] Example (N=3):

[0090] head=0→idx=0%3=0→Get the task parameters corresponding to index value 0;

[0091] head=1→idx=1%3=1→Get the task parameters corresponding to index value 1;

[0092] head=2→idx=2%3=2→Get the task parameters corresponding to index value 2;

[0093] head=3→idx=3%3=0→Get the task parameters corresponding to index value 0 (loop starts);

[0094] head=4→idx=4%3=1→Get the task parameters corresponding to index value 1;

[0095] ...

[0096] head=100→idx=100%3=1→Get the task parameters corresponding to index value 1.

[0097] In this embodiment, the asynchronous scheduler manages asynchronous tasks through a separate worker thread, supporting both graph capture and non-graph capture modes. It uses a semaphore mechanism to coordinate task execution between the computation processor and the task processor, ensuring the correctness and order of asynchronous operations. This design allows asynchronous tasks to be delayed during computation processor graph capture until the graph is started, thereby improving performance and reducing synchronization overhead. Simultaneously, by executing asynchronous tasks in separate threads, blocking the main computation flow can be avoided, enabling overlap between computation and communication.

[0098] This application provides a scheduling method for asynchronous tasks: in response to receiving a processing request for a computing task, generating task queue information corresponding to the computing task, the task queue information including task parameters corresponding to at least one type of asynchronous task; obtaining a first semaphore and a second semaphore corresponding to at least one type of asynchronous task; wherein, the first semaphore is used to indicate the amount of asynchronous tasks already processed by the task processor, and the second semaphore is used to indicate the amount of asynchronous tasks submitted by the computing processor to be processed; determining whether the first semaphore and the second semaphore corresponding to the asynchronous task of that type satisfy a preset condition variable, if so, waking up the asynchronous task thread, and reading the task parameters corresponding to the asynchronous task of that type from the task queue information through the asynchronous task thread, and executing the asynchronous task of that type according to the task parameters. In this embodiment, by waking up the asynchronous task thread through a semaphore mechanism, busy waiting of the asynchronous task thread is avoided. This means that the asynchronous task thread does not need to be in a working state all the time, reducing the server resources occupied by the asynchronous task thread and thus improving the resource utilization of the server cluster. Furthermore, waking up the asynchronous task thread through the first and second semaphores can balance the amount of tasks processed by the task processor and the amount of tasks submitted by the computing processor, ensuring the consistency of the task states of the task processor and the computing processor, reducing the waiting time of the computing processor, and further improving the resource utilization of the server cluster.

[0099] Figure 7 This is a schematic diagram of the structure of an asynchronous task scheduling device provided in an embodiment of this application. Figure 7 As shown, the scheduling device includes:

[0100] The generation module 701 is used to generate task queue information corresponding to the computing task in response to receiving a processing request for the computing task. The task queue information includes task parameters corresponding to at least one type of asynchronous task.

[0101] The acquisition module 702 is used to acquire a first semaphore and a second semaphore corresponding to at least one type of asynchronous task; wherein the first semaphore is used to indicate the amount of asynchronous tasks that the task processor has processed, and the second semaphore is used to indicate the amount of asynchronous tasks that the computing processor has submitted to be processed.

[0102] The scheduling module 703 is used to determine whether the first and second semaphores corresponding to the asynchronous task of a certain type meet the preset condition variables. If they do, the asynchronous task thread is woken up, and the asynchronous task thread reads the task parameters corresponding to the asynchronous task of a certain type from the task queue information and executes the asynchronous task of a certain type according to the task parameters.

[0103] In some embodiments, in response to receiving a processing request for a computing task, the generation module 701 generates task queue information corresponding to the computing task, including: in response to receiving a processing request for a computing task, obtaining a task mode identifier corresponding to the computing task and task parameters corresponding to at least one type of asynchronous task included in the computing task from the task information carried in the processing request; and generating task queue information corresponding to the computing task based on the task mode identifier and the task parameters corresponding to at least one type of asynchronous task.

[0104] In some embodiments, the generation module 701 generates task queue information corresponding to a computation task based on a task mode identifier and task parameters corresponding to at least one type of asynchronous task, including: if the task mode identifier indicates that the computation task is in graph capture mode, then the graph capture identifier corresponding to the computation task is obtained from the task information carried in the processing request, and graph task queue information corresponding to the computation task is generated based on the graph capture identifier and task parameters corresponding to at least one type of asynchronous task; if the task mode identifier indicates that the computation task is in non-graph capture mode, then non-graph task queue information corresponding to the computation task is generated based on task parameters corresponding to at least one type of asynchronous task.

[0105] In some embodiments, the generation module 701 generates graph task queue information corresponding to a computation task based on a graph capture identifier and task parameters corresponding to at least one type of asynchronous task, including: determining whether the computation task is a new graph task based on the graph capture identifier; wherein a new graph task is used to indicate that the graph task queue information does not include task parameters corresponding to at least one type of asynchronous task; if the computation task is a new graph task, determining the graph task identifier corresponding to at least one type of asynchronous task, generating a correspondence between the graph task identifier and the task parameters based on the graph task identifier corresponding to at least one type of asynchronous task and the task parameters corresponding to at least one type of asynchronous task, and adding the correspondence to the graph task queue information.

[0106] In some embodiments, the generation module 701 is further configured to, if the computation task is not a new graph task, obtain the amount of unprocessed tasks corresponding to at least one type of asynchronous task from the task information carried in the processing request, and accumulate the amount of unprocessed tasks into the second semaphore corresponding to the type of asynchronous task to obtain the updated second semaphore.

[0107] In some embodiments, the generation module 701 determines whether the computation task is a new graph task based on the graph capture identifier, including: querying whether a graph capture identifier already exists in the graph callback mapping table; wherein, the graph callback mapping table is used to store the mapping relationship between the graph capture identifier, the graph task identifier corresponding to the asynchronous task of the type, and the second semaphore corresponding to the asynchronous task of the type; if it exists, it is determined that the computation task is not a new graph task; if it does not exist, it is determined that the computation task is a new graph task.

[0108] In some embodiments, the generation module 701 is further configured to, if the computation task is a new graph task, obtain the amount of pending tasks submitted by the computation processor from the task information carried in the processing request, determine the amount of pending tasks as a second semaphore corresponding to the type of asynchronous task; establish a mapping relationship between the graph capture identifier, the graph task identifier corresponding to the type of asynchronous task, and the second semaphore corresponding to the type of asynchronous task, and store the mapping relationship in the graph callback mapping table.

[0109] In some embodiments, the generation module 701 generates non-graph task queue information corresponding to the computing task based on the task parameters corresponding to at least one type of asynchronous task, including: obtaining the amount of pending tasks submitted by the computing processor from the task information, appending the amount of pending tasks to the second semaphore corresponding to the type of asynchronous task, and adding the task parameters corresponding to at least one type of asynchronous task to the non-graph task queue information to generate non-graph task queue information corresponding to the computing task.

[0110] In some embodiments, the scheduling module 703 reads the task parameters corresponding to the asynchronous task of a certain type from the task queue information through the asynchronous task thread, and executes the asynchronous task of a certain type according to the task parameters, including: obtaining the number of multiple sub-task parameters included in the task parameters; reading the target sub-task parameter corresponding to the current asynchronous task from the multiple sub-task parameters included in the task parameters according to the first semaphore and the number; and executing the asynchronous task of a certain type according to the target sub-task parameter.

[0111] In some embodiments, the scheduling module 703 obtains the target subtask parameter corresponding to the current asynchronous task from multiple subtask parameters included in the task parameters based on the first semaphore and the quantity, including: performing a modulo operation on the first semaphore with the quantity as the modulus to obtain the target index value corresponding to the target subtask parameter; and obtaining the target subtask parameter corresponding to the target index value from the correspondence between the index value and multiple subtask parameters based on the target index value.

[0112] In some embodiments, the acquisition module 702 acquires the first semaphore and the second semaphore corresponding to each of at least one type of asynchronous task, including: acquiring the task priority corresponding to each of at least one type of asynchronous task; determining the execution order of at least one type of asynchronous task according to the task priority corresponding to each of at least one type of asynchronous task; and acquiring the first semaphore and the second semaphore corresponding to the asynchronous task of each type according to the order in which the at least one type of asynchronous task is executed.

[0113] In some embodiments, the acquisition module 702 acquires a first semaphore and a second semaphore corresponding to an asynchronous task of a certain type, including: acquiring a task identifier corresponding to the asynchronous task of a certain type; acquiring a first semaphore corresponding to the asynchronous task of a certain type from a host-side semaphore pool based on the task identifier; and acquiring a second semaphore corresponding to the asynchronous task of a certain type from a device-side semaphore pool based on the task identifier; wherein the host-side semaphore pool is used to store the correspondence between the task identifier and the first semaphore, and the device-side semaphore pool is used to store the correspondence between the task identifier and the second semaphore.

[0114] In some embodiments, the scheduling device further includes: a semaphore synchronization module; the semaphore synchronization module is configured to, in response to reading the task parameters corresponding to the asynchronous task of the type from the task queue information through the asynchronous task thread, increment the first semaphore corresponding to the asynchronous task of the type in the host-side semaphore pool by 1 to obtain the updated first semaphore; and in response to executing the asynchronous task of the type according to the task parameters, decrement the second semaphore corresponding to the asynchronous task of the type in the device-side semaphore pool by 1 to obtain the updated second semaphore.

[0115] In some embodiments, the scheduling device further includes a thread sleep module; the thread sleep module is used to determine whether the updated first semaphore and the updated second semaphore satisfy a preset condition variable; if they satisfy, the asynchronous task thread continues to read the task parameters corresponding to the asynchronous task of the type from the task queue information and executes the asynchronous task of the type according to the task parameters; if they do not satisfy, the asynchronous task thread is switched to a sleep state.

[0116] In some embodiments, the thread sleep module is further configured to determine the total number of tasks corresponding to the asynchronous task thread based on the updated second semaphore corresponding to each of at least one type of asynchronous task; if the total number of tasks is less than or equal to a first preset value, the asynchronous task thread is switched to a sleep state.

[0117] In some embodiments, the scheduling module 703 determines whether the first semaphore and the second semaphore corresponding to the asynchronous task of the type satisfy a preset condition variable, including: if the first semaphore corresponding to the asynchronous task of the type is less than the second semaphore, then the first semaphore and the second semaphore corresponding to the asynchronous task of the type satisfy the preset condition variable; if the first semaphore corresponding to the asynchronous task of the type is equal to the second semaphore, then the first semaphore and the second semaphore corresponding to the asynchronous task of the type do not satisfy the preset condition variable.

[0118] This application provides an asynchronous task scheduling device. By waking up asynchronous task threads through a semaphore mechanism, busy waiting of asynchronous task threads is avoided. This means that asynchronous task threads do not need to be in a working state all the time, reducing the server resources occupied by asynchronous task threads and thus improving the resource utilization of the server cluster. Furthermore, waking up asynchronous task threads through a first semaphore and a second semaphore can balance the amount of tasks processed by the task processor and the amount of tasks submitted by the computing processor, ensuring the consistency of task states between the task processor and the computing processor, reducing the waiting time of the computing processor, and further improving the resource utilization of the server cluster.

[0119] For a description of the features of the asynchronous task scheduling device provided in this application, please refer to the relevant description of the asynchronous task scheduling method. It will not be repeated here.

[0120] Figure 8 A schematic diagram of the structure of the electronic device provided in this application. Figure 8 As shown, the electronic device 80 provided in this embodiment includes at least one processor 801 and a memory 802. Optionally, the electronic device 80 further includes a communication component 803. The processor 801, memory 802, and communication component 803 are connected via a bus.

[0121] In a specific implementation, at least one processor 801 executes computer execution instructions stored in memory 802, causing at least one processor 801 to execute the above-described asynchronous task scheduling method embodiment.

[0122] The specific implementation process of processor 801 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.

[0123] In the above embodiments, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the application can be directly manifested as being executed by a hardware processor, or executed by a combination of hardware and software modules within the processor.

[0124] The memory may include random access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage device.

[0125] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.

[0126] Embodiments of this application also provide a computer-readable storage medium storing a computer program configured to execute the steps in any of the above-described asynchronous task scheduling method embodiments at runtime.

[0127] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.

[0128] Embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above-described asynchronous task scheduling method embodiments.

[0129] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps in any of the above-described asynchronous task scheduling method embodiments.

[0130] Any of the components, modules, units, parts, methods, and operations described herein can be implemented using software, firmware, hardware (e.g., fixed logic circuitry), manual processing, or any combination thereof. Alternatively or additionally, any functionality described herein can be executed at least in part by one or more hardware logic components, such as, but not limited to, a central processing unit (CPU), a field-programmable gate array (FPGA), an application-specific integrated circuit (ASIC), an application-specific standard product (ASSP), a system-on-a-chip (SoC), a complex programmable logic device (CPLD), a microprocessor (MCU), etc. The terms "system," "computing device," or "apparatus" as used herein encompass various means, devices, and machines for processing data, including, for example, one or more programmable processors, computers, SoCs, or combinations thereof. The apparatus may also include code that creates an execution environment for the computer program in question, such as code constituting processor firmware, a protocol stack, a database management system, an operating system, a cross-platform runtime environment, a virtual machine, or one or more combinations thereof. The aforementioned computer program (also known as a program, software, software application, app, script, or code) can be written in any form of programming language, including compiled or interpreted languages, declarative or procedural languages, and can be deployed in any form, including as a standalone program or as a module, component, subroutine, object, or other unit suitable for a computing environment.

[0131] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0132] The foregoing has provided a detailed description of an asynchronous task scheduling method, apparatus, device, storage medium, and program product provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are merely for the purpose of helping to understand the method and core ideas of this application. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of this application.

Claims

1. A method for scheduling asynchronous tasks, characterized in that, include: In response to receiving a processing request for a computing task, task queue information corresponding to the computing task is generated, and the task queue information includes task parameters corresponding to at least one type of asynchronous task. Obtain a first semaphore and a second semaphore corresponding to each of the at least one type of asynchronous task; wherein, the first semaphore is used to indicate the amount of asynchronous tasks that the task processor has processed, and the second semaphore is used to indicate the amount of asynchronous tasks that the computing processor has submitted to be processed. If the first semaphore corresponding to the asynchronous task of the aforementioned type is less than the second semaphore, then the asynchronous task thread is woken up, and the asynchronous task thread reads the task parameters corresponding to the asynchronous task of the aforementioned type from the task queue information, and executes the asynchronous task of the aforementioned type according to the task parameters; In response to reading the task parameters corresponding to the asynchronous task of the type from the task queue information through the asynchronous task thread, the first semaphore corresponding to the asynchronous task of the type in the host-side semaphore pool is incremented by 1 to obtain the updated first semaphore; In response to executing the asynchronous task of the type according to the task parameters, the second semaphore corresponding to the asynchronous task of the type in the device-side semaphore pool is decremented by 1 to obtain the updated second semaphore. If the updated first semaphore is less than the updated second semaphore, then the asynchronous task thread continues to read the task parameters corresponding to the asynchronous task of the same type from the task queue information, and executes the asynchronous task of the same type according to the task parameters. If the updated first semaphore is equal to the updated second semaphore, then the asynchronous task thread is switched to a sleep state.

2. The scheduling method according to claim 1, characterized in that, The step of generating task queue information corresponding to the received computing task processing request includes: In response to receiving a processing request for a computing task, the task mode identifier corresponding to the computing task and the task parameters corresponding to each of the at least one type of asynchronous task included in the computing task are obtained from the task information carried in the processing request. Based on the task mode identifier and the task parameters corresponding to each of the at least one type of asynchronous task, generate the task queue information corresponding to the computing task.

3. The scheduling method according to claim 2, characterized in that, The step of generating task queue information corresponding to the computation task based on the task mode identifier and the task parameters corresponding to each of the at least one type of asynchronous task includes: If the task mode identifier is used to indicate that the computing task is in graph capture mode, then the graph capture identifier corresponding to the computing task is obtained from the task information carried by the processing request, and graph task queue information corresponding to the computing task is generated according to the graph capture identifier and the task parameters corresponding to the at least one type of asynchronous task. If the task mode identifier is used to indicate that the computing task is a non-graph capture mode, then the non-graph task queue information corresponding to the computing task is generated according to the task parameters corresponding to each of the at least one type of asynchronous task.

4. The scheduling method according to claim 3, characterized in that, The step of generating graph task queue information corresponding to the computation task based on the graph capture identifier and the task parameters corresponding to each of the at least one type of asynchronous task includes: Based on the graph capture identifier, it is determined whether the computation task is a new graph task; wherein the new graph task is used to indicate that the graph task queue information does not include the task parameters corresponding to each of the at least one type of asynchronous task. If the computation task is a new graph task, then determine the graph task identifier corresponding to each of the at least one type of asynchronous task, generate a correspondence between the graph task identifier and the task parameters corresponding to each of the at least one type of asynchronous task, and add the correspondence to the graph task queue information.

5. The scheduling method according to claim 4, characterized in that, The method further includes: If the computation task is not a new graph task, then the amount of unprocessed tasks corresponding to each of the at least one type of asynchronous task is obtained from the task information carried by the processing request, and the amount of unprocessed tasks is added to the second semaphore corresponding to the asynchronous task of the type to obtain the updated second semaphore.

6. The scheduling method according to claim 4, characterized in that, Determining whether the computation task is a new graph task based on the graph capture identifier includes: Check if the graph capture identifier already exists in the graph callback mapping table; wherein, the graph callback mapping table is used to store the mapping relationship between the graph capture identifier, the graph task identifier corresponding to the asynchronous task of the type, and the second semaphore corresponding to the asynchronous task of the type; If it exists, then the computation task is determined not to be a new graph task; if it does not exist, then the computation task is determined to be a new graph task.

7. The scheduling method according to claim 6, characterized in that, The method further includes: If the computation task is a new graph task, then the amount of unprocessed tasks submitted by the computation processor is obtained from the task information carried by the processing request, and the amount of unprocessed tasks is determined as the second semaphore corresponding to the asynchronous task of the type. Establish a mapping relationship between the graph capture identifier, the graph task identifier corresponding to the asynchronous task of the type, and the second semaphore corresponding to the asynchronous task of the type, and store the mapping relationship in the graph callback mapping table.

8. The scheduling method according to claim 3, characterized in that, The step of generating non-graph task queue information corresponding to the computation task based on the task parameters corresponding to each of the at least one type of asynchronous task includes: The amount of pending tasks submitted by the computing processor is obtained from the task information, the amount of pending tasks is appended to the second semaphore corresponding to the asynchronous task of the type, and the task parameters corresponding to the at least one type of asynchronous task are added to the non-graph task queue information to generate the non-graph task queue information corresponding to the computing task.

9. The scheduling method according to claim 1, characterized in that, The step of reading the task parameters corresponding to the asynchronous task of the type from the task queue information through the asynchronous task thread, and executing the asynchronous task of the type according to the task parameters, includes: Obtain the number of sub-task parameters included in the task parameters; Based on the first semaphore and the quantity, read the target subtask parameters corresponding to this asynchronous task from the multiple subtask parameters included in the task parameters; Execute the asynchronous task of the type described above based on the target subtask parameters.

10. The scheduling method according to claim 9, characterized in that, The step of obtaining the target subtask parameter corresponding to this asynchronous task from multiple subtask parameters included in the task parameters based on the first semaphore and the quantity includes: Using the quantity as a modulus, perform a modulo operation on the first semaphore to obtain the target index value corresponding to the target subtask parameter; Based on the target index value, the target subtask parameters corresponding to the target index value are obtained from the correspondence between the index value and multiple subtask parameters.

11. The scheduling method according to claim 1, characterized in that, The step of obtaining the first and second semaphores corresponding to each of the at least one type of asynchronous task includes: Obtain the task priority corresponding to each of the at least one type of asynchronous task; The execution order of the at least one type of asynchronous task is determined according to the task priority corresponding to each of the at least one type of asynchronous task; Obtain the first and second semaphores corresponding to the asynchronous tasks of the at least one type in the order in which they are executed.

12. The scheduling method according to claim 11, characterized in that, The step of obtaining the first and second semaphores corresponding to the asynchronous task of the aforementioned type includes: Obtain the task identifier corresponding to the asynchronous task of the aforementioned type; The system retrieves a first semaphore corresponding to the asynchronous task of the specified type from the host-side semaphore pool based on the task identifier, and retrieves a second semaphore corresponding to the asynchronous task of the specified type from the device-side semaphore pool based on the task identifier; wherein the host-side semaphore pool is used to store the correspondence between the task identifier and the first semaphore, and the device-side semaphore pool is used to store the correspondence between the task identifier and the second semaphore.

13. The scheduling method according to claim 1, characterized in that, The method further includes: The total number of tasks corresponding to the asynchronous task thread is determined based on the updated second semaphore corresponding to each of the at least one type of asynchronous task. If the total number of tasks is less than or equal to a first preset value, the asynchronous task thread will be switched to a sleep state.

14. A scheduling device for asynchronous tasks, characterized in that, The scheduling device includes: A generation module is used to generate task queue information corresponding to the received computing task in response to the processing request of the computing task. The task queue information includes task parameters corresponding to at least one type of asynchronous task. The acquisition module is used to acquire a first semaphore and a second semaphore corresponding to each of the at least one type of asynchronous task; wherein the first semaphore is used to indicate the amount of asynchronous tasks that the task processor has processed, and the second semaphore is used to indicate the amount of asynchronous tasks that the computing processor has submitted to be processed. The scheduling module is used to determine that if the first semaphore corresponding to the asynchronous task of the type is less than the second semaphore, then wake up the asynchronous task thread, and read the task parameters corresponding to the asynchronous task of the type from the task queue information through the asynchronous task thread, and execute the asynchronous task of the type according to the task parameters; The semaphore synchronization module is used to respond to reading the task parameters corresponding to the asynchronous task of the type from the task queue information through the asynchronous task thread, incrementing the first semaphore corresponding to the asynchronous task of the type in the host-side semaphore pool by 1, and obtaining the updated first semaphore; In response to executing the asynchronous task of the type according to the task parameters, the second semaphore corresponding to the asynchronous task of the type in the device-side semaphore pool is decremented by 1 to obtain the updated second semaphore. The thread sleep module is used to continue reading the task parameters corresponding to the asynchronous task of the type from the task queue information through the asynchronous task thread if the updated first semaphore is less than the updated second semaphore, and to execute the asynchronous task of the type according to the task parameters. If the updated first semaphore is equal to the updated second semaphore, then the asynchronous task thread is switched to a sleep state.

15. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for implementing the scheduling method for asynchronous tasks as described in any one of claims 1 to 13 when executing the computer program.

16. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the scheduling method for asynchronous tasks as described in any one of claims 1 to 13.

17. A computer program product, characterized in that, Includes a computer program, wherein the computer program, when executed by a processor, implements the scheduling method for asynchronous tasks as described in any one of claims 1 to 13.

Citation Information

Patent Citations

  • Dynamic multi-thread scheduling method and system

    CN112395063A

  • Asynchronous task processing method and device, computer equipment and storage medium

    CN116302427A