Gpu task creation system, method, graphics processor, electronic device

By introducing a task scheduler and caching mechanism into the GPU, the problems of excessive CPU load and low GPU efficiency while waiting for subtasks are solved, resulting in more efficient task execution and reduced power consumption.

CN120909745BActive Publication Date: 2025-12-09MOORE THREADS TECHNOLOGY (SHANGHAI) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511454358.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-10-13
Publication Date
2025-12-09
Estimated Expiration
2045-10-13

AI Technical Summary

Technical Problem

In traditional GPU applications, task creation and scheduling are handled by the CPU, which overburdens the CPU. The GPU is inefficient while waiting for the CPU to create subtasks, and frequent interactions with memory increase power consumption.

Method used

In a GPU, a task scheduler, N processor cores, N first caches, and a shared second cache are set up. When a processor core executes a task, it stores the subtask parameters in the first cache and requests a storage area in the second cache. After all threads have completed, the task scheduler moves the parameters to the second cache, and the processor cores directly obtain the parameters from the second cache.

Benefits of technology

It improves the GPU's task execution efficiency, reduces power consumption, reduces interaction with memory, and increases GPU utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120909745B_ABST
    Figure CN120909745B_ABST
Patent Text Reader

Abstract

The present disclosure relates to the field of graphic processors, and provides a GPU task creation system, method, graphic processor and electronic device. The system comprises a task scheduler, N processor cores, N first caches, a second cache, the scheduler schedules tasks to the processor cores for execution; the processor cores execute the received tasks, including starting threads; obtaining task parameters; executing threads using the task parameters; when creating a subtask in the process of executing a thread, storing the task parameters of the subtask to the first cache corresponding to the processor core; applying a storage area in the second cache for storing the task parameters of the subtask; the scheduler is configured to notify the first cache corresponding to each processor core to move the task parameters of the subtask to the corresponding storage area in the second cache, and when the processor core receives the subtask, access the second cache to obtain the task parameters of the subtask. The GPU task creation system provided in the present disclosure can improve the work efficiency of the GPU and reduce the power consumption of the GPU.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure relates to the field of graphics processors, and particularly relates to a GPU task creation system and method, a graphics processor and an electronic device. BACKGROUND

[0002] In a traditional GPU application scenario, the creation and scheduling of tasks are usually completed by a CPU. However, when the number of tasks is large and changes frequently, the CPU needs to intervene frequently, which increases the burden of the CPU. In some application scenarios, the GPU needs to create sub-tasks when executing a task, and the GPU needs to wait for the CPU to create the sub-tasks during the execution of the task, which reduces the task execution efficiency of the GPU. If no new task is executed during the waiting process, the utilization of the GPU will be reduced.

[0003] If the GPU can create tasks, the burden of the CPU can be reduced, the task execution efficiency of the GPU can be improved, and the utilization of the GPU can be improved. Therefore, how to enable the GPU to create tasks has become a research hotspot in the field.

[0004] Although some existing GPUs support task creation, the process of creating tasks and executing the created tasks needs to frequently interact with a memory, which reduces the working efficiency of the GPU and increases the power consumption of the GPU. SUMMARY

[0005] In view of this, the present disclosure provides a GPU task creation system and method, a graphics processor and an electronic device. The GPU task creation system of the embodiments of the present disclosure can improve the working efficiency of the GPU and reduce the power consumption of the GPU.

[0006] According to an aspect of the present disclosure, a GPU task creation system is provided. The system is arranged in a GPU, and includes a task scheduler, N processor cores, N first caches and a second cache. The N first caches correspond to the N processor cores one by one, and the second cache is shared by the N processor cores. N is a positive integer. The task scheduler is configured to schedule a task to be executed to at least one processor core for execution. Any one of the processor cores is configured to execute the received task, including starting at least one thread, obtaining task parameters of the received task, executing the thread using the task parameters, and storing task parameters of a sub-task to a first cache corresponding to the processor core when creating the sub-task in the process of executing the thread. The second cache is configured to apply a storage area for storing the task parameters of the sub-task. The task scheduler is configured to notify the first cache corresponding to each processor core to move the task parameters of the sub-task to a corresponding storage area in the second cache when all the threads started by each processor core are executed. When the processor core receives the sub-task, the processor core accesses the second cache to obtain the task parameters of the sub-task.

[0007] In a possible implementation, the task to be executed includes a parent task created by a CPU and a to-be-executed child task created by the system, and the task scheduler is further configured to: count a first thread number, the first thread number being a total number of threads of the to-be-executed child task created by the system; when the first thread number reaches a first value, notify a processor core executing the parent task to stop executing the parent task and start scheduling the to-be-executed child task created by the system to at least one processor core for execution, the first value being a product of the maximum number of threads executed in parallel by the GPU and a saturation ratio; and when the first thread number is less than the first value, notify the processor core executing the parent task to continue executing the parent task.

[0008] In a possible implementation, the task scheduler is further configured to count execution information of the to-be-executed child task, the execution information indicating a number of times of execution of the child task and a storage area of the task parameter of the child task in the second cache each time the child task is executed; and any one of the processor cores is further configured to transmit, to the task scheduler, creation information of the child task, the creation information including a pointer of a data structure of the child task, a number of the storage area of the task parameter of the child task in the second cache, and the number of times of execution of the child task; and the task scheduler is further configured to update the execution information of the child task according to the creation information of the child task, and output, to any one of the processor cores, a storage location of the task parameter of the child task according to the execution information of the child task when scheduling any one of the child tasks to any one of the processor cores.

[0009] In a possible implementation, the second cache includes a parameter storage space for data writing and a parameter storage space for data reading, and any one of the processor cores is specifically configured to apply for a storage area in the parameter storage space for data writing; the task scheduler is further configured to change the parameter storage space for data writing to the parameter storage space for data reading and change the parameter storage space for data reading to the parameter storage space for data writing after the first cache moves the task parameter of the to-be-executed child task to the corresponding storage area in the second cache; the storage location of the task parameter output by the task scheduler to any one of the processor cores belongs to the parameter storage space for data reading; and the processor core is specifically configured to access the parameter storage space for data reading to obtain the task parameter of the child task according to the received storage location.

[0010] In a possible implementation, the task scheduler comprises a first index table and a second index table, the second cache comprises a third index table, the execution information of the subtask comprises a first execution information and a plurality of second execution information, each second execution information corresponds to an execution of the subtask, an i-th entry of the first index table corresponds to an i-th subtask to be executed, and is used to store first execution information corresponding to the i-th subtask, the first execution information corresponding to the i-th subtask comprises a pointer of a data structure of the i-th subtask, and a storage area number of second execution information corresponding to a first execution of the i-th subtask in the third index table, i is a positive integer; a j-th entry of the second index table corresponds to a k-th execution of the i-th subtask to be executed, and is used to store second execution information corresponding to the k-th execution of the i-th subtask and a storage area number of the second execution information corresponding to the k-th execution of the i-th subtask in the third index table, the second execution information corresponding to the k-th execution of the i-th subtask comprises a storage area number of a task parameter used by the i-th subtask in the k-th execution in the second cache, a length of the task parameter used by the i-th subtask in the k-th execution, a storage area number of second execution information corresponding to a k+1-th execution of the i-th subtask in the third index table, and a subsequent execution number of the i-th subtask, j and k are positive integers.

[0011] In a possible implementation, the task scheduler is specifically configured to: query, according to the creation information of the subtask, whether execution information of the same subtask has been stored in the task scheduler; when the execution information of the same subtask has not been stored in the task scheduler, select an entry from the first index table to store first execution information corresponding to the subtask, select an entry from the second index table to store a group of second execution information corresponding to the subtask, and apply an entry from the third index table to store the group of second execution information corresponding to the subtask; write a pointer of a data structure of the subtask into the selected entry in the first index table; write, as a number of a storage area of the task parameter used by the first execution of the subtask in the second cache, a number of the applied entry in the third index table into the selected entries in the first index table and the second index table; write, as a number of a storage area of the task parameter used by the first execution of the subtask in the second cache, a number included in the creation information into the selected entry in the second index table; write, as a length of the task parameter used by the first execution of the subtask, a length of the task parameter of the subtask into the selected entry in the second index table; write, as a number of an entry corresponding to the second execution of the subtask in the third index table, an invalid identifier into the selected entry in the second index table; and write 1, as a number of subsequent executions of the subtask, into the selected entry in the second index table.

[0012] In a possible implementation, the task scheduler is specifically configured to: query, according to the creation information of the subtask, whether execution information of the same subtask has been stored in the task scheduler; when the execution information of the same subtask has been stored in the task scheduler, and the same subtask is the ith subtask, query the second index table and / or the third index table to determine all second execution information corresponding to the first x executions of the ith subtask, and when any group of second execution information satisfies a first condition, add a length of the task parameter of the subtask to a length of the task parameter included in the second execution information, and add a number of executions of the subtask to a number of subsequent executions of the subtask included in the second execution information; x is a smaller one of a second value and a total number of executions of the ith subtask, and x is a positive integer; and the first condition is that a sum of a number of a storage area of a task parameter used by an execution corresponding to the second execution information in the second cache and the length of the task parameter is equal to a number included in the creation information.

[0013] In a possible implementation, the first execution of the ith subtask corresponds to the pth entry in the second index table, p is a positive integer, and the task scheduler is specifically configured to: select an entry from the second index table to store a set of second execution information corresponding to the ith subtask, when there is no entry satisfying the first condition; apply an entry in the third index table to store a set of second execution information corresponding to the ith subtask; write, in the selected entry in the second index table, a number of the applied entry in the third index table as a number of a storage area in the third index table corresponding to the second execution information corresponding to the first execution of the ith subtask; write, in the selected entry in the second index table, a number included in the creation information as a number of a storage area in the second cache used by the task parameter used in the first execution of the ith subtask; write, in the selected entry in the second index table, a length of the task parameter of the subtask as a length of the task parameter used in the first execution of the ith subtask; write, in the selected entry in the second index table, a number stored in the entry corresponding to the ith subtask in the first index table as a number of the entry corresponding to the second execution of the ith subtask in the third index table; write, in the selected entry in the second index table, a sum of the execution number of the subtask and a subsequent execution number stored in the pth entry as the subsequent execution number of the ith subtask; and update the number stored in the entry corresponding to the ith subtask in the first index table to the number of the applied entry in the third index table.

[0014] In a possible implementation, the task scheduler is specifically configured to: query whether the first index table has stored the pointer included in the creation information; determine that the task scheduler has stored the execution information of the same subtask, when the first index table has stored the pointer included in the creation information; and determine that the task scheduler has not stored the execution information of the same subtask, when the first index table has not stored the pointer included in the creation information.

[0015] In a possible implementation, the first index table, the second index table and the third index table each include a linked list for data writing and a linked list for data reading, and the task scheduler is specifically configured to: select an entry from the linked list for data writing when selecting an entry from the first index table and the second index table; apply for an entry from the linked list for data writing when applying for an entry from the third index table; and change the linked list for data writing to the linked list for data reading and change the linked list for data reading to the linked list for data writing after the corresponding first cache of each processor core is notified to move the task parameters of the to-be-executed subtask to the corresponding storage area in the second cache; and the task scheduler is specifically configured to: query the linked list for data reading when querying the first index table, the second index table and the third index table.

[0016] According to another aspect of the present disclosure, a graphics processor is provided, including the GPU task creation system of any of the above.

[0017] According to another aspect of the present disclosure, an electronic device is provided, including the graphics processor of the above.

[0018] According to another aspect of the present disclosure, a GPU task creation method is provided, the method is executed by a GPU task creation system, the system is arranged in a GPU, and the system includes a task scheduler, N processor cores, N first caches and a second cache, the N first caches correspond to the N processor cores one by one, the second cache is shared by the N processor cores, and N is a positive integer; the method includes: scheduling a to-be-executed task to at least one processor core for execution by using the task scheduler; and executing the received task by using any one processor core, including: starting at least one thread; obtaining task parameters of the received task; executing the thread by using the task parameters; storing task parameters of a subtask to a first cache corresponding to the processor core when the subtask is created in the process of executing the thread; applying a storage area in the second cache for storing the task parameters of the subtask; and notifying the first cache corresponding to each processor core to move the task parameters of the subtask to a corresponding storage area in the second cache when all the threads started by the processor core are executed by using the task scheduler, and the processor core accesses the second cache to obtain the task parameters of the subtask when the processor core receives the subtask.

[0019] In a possible implementation, the task to be executed includes a parent task created by a CPU and a to-be-executed child task created by the system, and the method further includes: using the task scheduler to further count a first thread number, the first thread number being a total number of threads of the to-be-executed child task created by the system; when the first thread number reaches a first value, using the task scheduler to notify a processor core executing the parent task to stop executing the parent task and start scheduling the to-be-executed child task created by the system to at least one processor core for execution, the first value being a product of the maximum number of threads executed in parallel by the GPU and a saturation ratio; when the first thread number is less than the first value, using the task scheduler to notify the processor core executing the parent task to continue executing the parent task.

[0020] In a possible implementation, the method further includes: using the task scheduler to count execution information of the to-be-executed child task, the execution information indicating a number of times of execution of the child task, and a storage area of the task parameter of the child task in the second cache each time the child task is executed; using the task scheduler to transmit, to the task scheduler, creation information of the child task, the creation information including a pointer of a data structure of the child task, a number of the storage area of the task parameter of the child task in the second cache, and the number of times of execution of the child task; using the task scheduler to update the execution information of the child task according to the creation information of the child task; and using the task scheduler to output, to the processor core, a storage location of the task parameter of the child task according to the execution information of the child task when scheduling any child task to any processor core.

[0021] In a possible implementation, the second cache includes a parameter storage space for data writing and a parameter storage space for data reading, and the method further includes: applying for a storage area in the parameter storage space for data writing; and after the first cache moves the task parameter of the to-be-executed child task to the corresponding storage area in the second cache, using the task scheduler to change the parameter storage space for data writing to the parameter storage space for data reading, and change the parameter storage space for data reading to the parameter storage space for data writing; when the task scheduler schedules any child task to any processor core, the task scheduler outputs, to the processor core, a storage location of the task parameter belonging to the parameter storage space for data reading; and when the processor core receives the child task, the processor core accesses the second cache to obtain the task parameter of the child task, including: the processor core accesses the parameter storage space for data reading according to the received storage location to obtain the task parameter of the child task.

[0022] In a possible implementation, the task scheduler comprises a first index table and a second index table, the second cache comprises a third index table, the execution information of the subtask comprises a first execution information and a plurality of second execution information, each second execution information corresponds to an execution of the subtask, an i-th entry of the first index table corresponds to an i-th subtask to be executed, and is used to store first execution information corresponding to the i-th subtask, the first execution information corresponding to the i-th subtask comprises a pointer of a data structure of the i-th subtask, and a storage area number of second execution information corresponding to a first execution of the i-th subtask in the third index table, i is a positive integer; a j-th entry of the second index table corresponds to a k-th execution of the i-th subtask to be executed, and is used to store second execution information corresponding to the k-th execution of the i-th subtask and a storage area number of the second execution information corresponding to the k-th execution of the i-th subtask in the third index table, the second execution information corresponding to the k-th execution of the i-th subtask comprises a storage area number of a task parameter used by the i-th subtask in the k-th execution in the second cache, a length of the task parameter used by the i-th subtask in the k-th execution, a storage area number of second execution information corresponding to a k+1-th execution of the i-th subtask in the third index table, and a subsequent execution number of the i-th subtask, j and k are positive integers.

[0023] In a possible implementation, the updating the execution information of the subtask according to the creation information of the subtask comprises: querying whether the execution information of the same subtask has been stored in the task scheduler according to the creation information of the subtask; when the execution information of the same subtask has not been stored in the task scheduler, selecting an entry from the first index table for storing the first execution information corresponding to the subtask, selecting an entry from the second index table for storing the group of second execution information corresponding to the subtask, and applying an entry in the third index table for storing the group of second execution information corresponding to the subtask; writing the pointer of the data structure of the subtask into the selected entry in the first index table, writing the number of the applied entry in the third index table as the number of the storage area of the second execution information corresponding to the first execution of the subtask in the third index table into the selected entries in the first index table and the second index table, writing the number included in the creation information as the number of the storage area of the task parameter used in the first execution of the subtask in the second cache into the selected entry in the second index table, writing the length of the task parameter of the subtask as the length of the task parameter used in the first execution of the subtask into the selected entry in the second index table, and writing the invalid identifier as the number of the entry corresponding to the second execution of the subtask in the third index table into the selected entry in the second index table; and writing 1 as the number of subsequent executions of the subtask into the selected entry in the second index table.

[0024] In a possible implementation, the updating the execution information of the subtask according to the creation information of the subtask comprises: querying whether the execution information of the same subtask has been stored in the task scheduler according to the creation information of the subtask; when the execution information of the same subtask has been stored in the task scheduler, and the same subtask is the ith subtask, querying the second index table and / or the third index table to determine all the second execution information corresponding to the first x executions of the ith subtask, and when any one of the group of second execution information satisfies a first condition, adding the length of the task parameter of the subtask to the length of the task parameter included in the second execution information, and adding the number of executions of the subtask to the number of subsequent executions of the subtask included in the second execution information; x is the smaller one of a second value and the total number of executions of the ith subtask, and x is a positive integer; and the first condition is that the sum of the number of the storage area of the task parameter used in the execution corresponding to the second execution information in the second cache and the length of the task parameter is equal to the number included in the creation information.

[0025] In a possible implementation, the first execution of the ith subtask corresponds to the pth entry in the second index table, p is a positive integer, and the updating of the execution information of the subtask according to the creation information of the subtask includes: when there is no entry satisfying the first condition, selecting an entry from the second index table to store a set of second execution information corresponding to the ith subtask; applying an entry in the third index table to store a set of second execution information corresponding to the ith subtask; writing, in the selected entry in the second index table, a number of the applied entry in the third index table as a number of a storage area of the third index table corresponding to the second execution information corresponding to the first execution of the ith subtask; writing, in the selected entry in the second index table, a number included in the creation information as a number of a storage area of the second cache corresponding to the task parameter used by the first execution of the ith subtask; writing, in the selected entry in the second index table, a length of the task parameter of the subtask as a length of the task parameter used by the first execution of the ith subtask; writing, in the selected entry in the second index table, a number stored in the entry corresponding to the ith subtask in the first index table as a number of the entry corresponding to the second execution of the ith subtask in the third index table; writing, in the selected entry in the second index table, a sum of the execution times of the subtask and the subsequent execution times stored in the pth entry as the subsequent execution times of the ith subtask; and updating the number stored in the entry corresponding to the ith subtask in the first index table to the number of the applied entry in the third index table.

[0026] In a possible implementation, the querying of whether the execution information of the same subtask has been stored in the task scheduler according to the creation information of the subtask includes: querying whether the first index table has stored the pointer included in the creation information; determining that the execution information of the same subtask has been stored in the task scheduler when the first index table has stored the pointer included in the creation information; and determining that the execution information of the same subtask has not been stored in the task scheduler when the first index table has not stored the pointer included in the creation information.

[0027] In a possible implementation, the first index table, the second index table, and the third index table each include a linked list for data writing and a linked list for data reading, the task scheduler selects an entry from the linked list for data writing when selecting an entry from the first index table and the second index table, and applies for an entry from the linked list for data writing when applying for an entry from the third index table; the method further includes that, after the task scheduler notifies each processor core corresponding to the first cache to move the task parameters of the to-be-executed subtask to the corresponding storage area in the second cache, the linked list for data writing is changed to the linked list for data reading, and the linked list for data reading is changed to the linked list for data writing; when the task scheduler queries the first index table, the second index table, and the third index table, the linked list for data reading is queried.

[0028] The GPU task creation system according to the embodiment of the present disclosure is applied to a GPU, and includes a task scheduler, N processor cores, N first caches, and a second cache. The N first caches correspond to the N processor cores one by one, and N is a positive integer. The task scheduler schedules a to-be-executed task to at least one processor core for execution. Any one processor core is configured to execute a received task, including starting at least one thread, obtaining task parameters of the received task, and executing the thread using the task parameters. When a subtask is created in the process of executing the thread, the task parameters of the subtask are stored in a first cache corresponding to the processor core. The second cache is configured to apply a storage area for storing the task parameters of the subtask. The task scheduler is configured to notify each first cache corresponding to a processor core to move the task parameters of the subtask to a corresponding storage area in the second cache when all the threads started by the processor core are executed. When a processor core receives a subtask, the processor core accesses the second cache to obtain the task parameters of the subtask. The task parameters of the subtask are stored in the first cache corresponding to the processor core when the subtask is created, so that the storage speed of the task parameters is faster, the task execution efficiency of the processor core is improved, and the working efficiency of the GPU is further improved. The task manager notifies each first cache corresponding to a processor core to move the task parameters to the second cache. The second cache is a cache shared by multiple processor cores, so that each processor core can obtain the task parameters of the subtask when executing the subtask. The GPU task creation system can execute the created subtask, and the working efficiency of the GPU can be improved compared with waiting for a CPU to create a subtask. The task parameters are stored in the second cache instead of the memory, so that the speed of storing the task parameters in the second cache and obtaining the task parameters by the processing module is faster, the working efficiency of the GPU is improved, and the power consumption of moving the task parameters is smaller. In summary, the GPU task creation system according to the embodiment of the present disclosure can improve the working efficiency of the GPU and reduce the power consumption of the GPU.

[0029] Other features and aspects of the present disclosure will become apparent from a detailed description of exemplary embodiments with reference to the following drawings. BRIEF DESCRIPTION OF DRAWINGS

[0030] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate exemplary embodiments, features, and aspects of the present disclosure and serve to explain the principles of the present disclosure.

[0031] Figure 1 A schematic diagram showing a method of GPU task creation according to prior art.

[0032] Figure 2 An exemplary application scenario of a GPU task creation system according to embodiments of the present disclosure is shown.

[0033] Figure 3 A schematic diagram showing the structure of a GPU task creation system according to embodiments of the present disclosure is shown.

[0034] Figure 4 A schematic diagram showing the structure of a second cache according to embodiments of the present disclosure is shown.

[0035] Figure 5 A schematic diagram showing the storage manner of execution information in a GPU task creation system according to embodiments of the present disclosure is shown.

[0036] Figure 6a An example of a first index table according to embodiments of the present disclosure is shown.

[0037] Figure 6b An example of a second index table according to embodiments of the present disclosure is shown.

[0038] Figure 7a A schematic diagram showing an updated first index table according to embodiments of the present disclosure is shown.

[0039] Figure 7b A schematic diagram showing an updated second index table according to embodiments of the present disclosure is shown.

[0040] Figure 8 A schematic diagram showing an updated second index table according to embodiments of the present disclosure is shown.

[0041] Figure 9a A schematic diagram showing an updated first index table according to embodiments of the present disclosure is shown.

[0042] Figure 9b A schematic diagram showing an updated second index table according to embodiments of the present disclosure is shown.

[0043] Figure 10 A schematic diagram showing the structure of a first index table, a second index table, and a third index table according to embodiments of the present disclosure is shown.

[0044] Figure 11 A schematic diagram showing a flow of a GPU task creation method according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0045] Various exemplary embodiments, features, and aspects of the present disclosure will be explained in greater detail below with reference to the accompanying drawings. Like reference numerals may be used to refer to like elements throughout. While various aspects of embodiments will be described in the drawings and specification, no limitation of the scope of the present disclosure is to be bound or otherwise limited by the drawings and specification, unless the drawings and specification are specifically indicated to the contrary.

[0046] As used herein, the terms "comprise", "comprising", "have", "having", "include", "including", "contain", "containing", or variants thereof are open-ended, and include one or more stated features, integers, elements, steps, components or functions but do not preclude the presence or addition of one or more other features, integers, elements, steps, components, functions or groups thereof.

[0047] When an element is referred to as being "connected", "coupled", "responsive", or "related" to another element, it can be directly connected, coupled, responsive, or related to the other element, or intervening elements can be present.

[0048] Although the terms first, second, third, etc. can be used herein to describe various elements / operations, these elements / operations should not be limited by these terms. These terms are only used to distinguish one element / operation from another element / operation. Thus, a first element / operation in some embodiments could be termed a second element / operation in other embodiments without departing from the teachings of the present inventive concept.

[0049] The word "exemplary" is used herein to mean "serving as an example, instance, or illustration." Any implementation described herein as "exemplary" is not necessarily to be construed as preferred or advantageous over other implementations.

[0050] In addition, for the purpose of convenience and brevity, detailed descriptions of well-known functions and structures incorporated in the present disclosure can be omitted. It will be appreciated that the present disclosure can be practiced with the exact details as other methods, schemes, elements, and circuits well known in the art are not described in detail.

[0051] Figure 1 A schematic diagram showing a method of creating a task by a GPU of the prior art is shown.

[0052] As Figure 1 shown, the GPU includes a core, a task scheduler, a memory system. The memory system stores a node list corresponding to a task (e.g., task 1 and task 2) created by the GPU.

[0053] When the GPU needs to create a task, a core running a shader (not shown) applies for a node from the memory system for storing task parameters. The memory system returns the address of the applied node to the shader.

[0054] According to the node address, the shader writes the task parameters into the applied node and adds the node into a node list corresponding to the task in the memory system. The shader passes the number of the task to the task scheduler to inform the task scheduler that a new task is generated.

[0055] According to the number of the received task, the task scheduler accesses the node list corresponding to the task in the memory system to obtain the task parameters. The task scheduler sends the task parameters to the core. The task scheduler informs the memory system to release the node where the sent task parameters are located from the node list corresponding to the task.

[0056] The scheme has the following disadvantages:

[0057] 1. For the shader, the application of the node and the storage of the task parameters need to be directly and frequently interacted with the memory system, and the cache cannot be utilized. For the task scheduler, the reading of the task parameters and the release of the node also need to be directly and frequently interacted with the memory system, and the cache cannot be utilized. This reduces the working efficiency of the GPU and increases the power consumption of the GPU.

[0058] 2. The node list corresponding to the task is read and written by the GPU core and the task scheduler at the same time, and a complex mechanism is needed to avoid the read-write conflict.

[0059] 3. The dynamic application and release of the node in the memory system are usually controlled by software, and are difficult to be implemented by hardware.

[0060] Therefore, the present disclosure provides a GPU task creation system, method, graphic processor and electronic device. The GPU task creation system can improve the working efficiency of the GPU and reduce the power consumption of the GPU.

[0061] Further, the GPU task creation system can avoid the read-write conflict of the task parameters, can dynamically apply and release the storage area of the task parameters by hardware, and improves the utilization rate of the GPU.

[0062] Figure 2 An exemplary application scenario of the GPU task creation system according to an embodiment of the present disclosure is shown.

[0063] As shown in Figure 2 , the electronic device can include a graphic processor (GPU) and a central processing unit (CPU). The GPU task creation system can be arranged in the GPU.

[0064] The CPU first creates a parent task, which can be, for example, a rendering task or a computation task. This embodiment does not limit the type of parent task. The parent task carries a pointer to its data structure (task meta data ptr), which stores attribute information such as the parent task's code address, the total number of threads, and its dimensions. The CPU can write the parent task's task parameters into the GPU's DDR memory. Task parameters include parameters used when executing the task, typically ranging from 4 to 128 bytes in length, depending on the task type; different types of tasks may use different parameters.

[0065] The CPU sends the created parent task and the storage location of the parent task's task parameters to the GPU. The GPU task creation system retrieves the parent task's task parameters from DDR based on the received storage location and executes the parent task using these parameters. During the execution of the parent task, the GPU task creation system creates subtasks based on the parent task's execution status. The GPU task creation system can preferentially store the subtask's task parameters in its own caches (such as the first cache and second cache described later), and only store them in DDR when necessary, such as when cache space is insufficient. The GPU task creation system can select an appropriate time point (such as when the first number of threads exceeds a certain value, as described later) to execute the subtask based on the parent task's execution status. If the subtask's task parameters are stored in the GPU task creation system, the system-stored task parameters can be used directly when executing the subtask without accessing memory. The GPU task creation system may also create new subtasks when executing subtasks. The execution method of new subtasks can be the same as that of subtasks created from the parent task. The GPU task creation system can execute parent and subtasks in the above manner until the parent task and all subtasks have been executed.

[0066] Figure 3 A schematic diagram illustrating the structure of a GPU task creation system according to an embodiment of the present disclosure is shown.

[0067] like Figure 3 As shown, in one possible implementation, the system is set in the GPU, and the system includes a task scheduler, N processor cores, N first caches, and a second cache. The N first caches correspond one-to-one with the N processor cores, and the second cache is shared by the N processor cores, where N is a positive integer.

[0068] The task scheduler is used to schedule tasks to be executed to at least one processor core;

[0069] Any processor core is used to execute the received task, including starting at least one thread; obtaining the task parameters of the received task; executing the thread using the task parameters; when creating a subtask during the execution of the thread, storing the task parameters of the subtask in its corresponding first cache; and allocating a storage area in the second cache to store the task parameters of the subtask.

[0070] The task scheduler is used to notify the first cache of each processor core to move the task parameters of the subtask to the corresponding storage area in the second cache when all the threads started by each processor core have finished executing. When the processor core receives the subtask, it accesses the second cache to obtain the task parameters of the subtask.

[0071] For example, such as Figure 3 As shown, the GPU task creation system may include a task scheduler, processor cores 1-N, first cache 1-N, and a second cache. The second cache is shared by processor cores 1-N, and each processor core can access its corresponding first cache and second cache.

[0072] The task scheduler can schedule tasks to be executed on at least one processor core. This step can be implemented based on existing technology; details of task scheduling are given later. Figure 3 In the example, the task scheduler first schedules task 0 to processor core 1 for execution.

[0073] The processor core is responsible for executing the received tasks. Executing a task includes the following steps:

[0074] Step 1: Start at least one thread, where the number of threads started can be specified by the task scheduler.

[0075] Step 2: Obtain the task parameters of the received task. This can be done by the task scheduler specifying the storage location of the task parameters and the processor core accessing the storage location to obtain the task parameters, or by the task scheduler directly outputting the task parameters to the processor core. This embodiment does not limit the specific method by which the processor core obtains the task parameters.

[0076] Step 3: Execute the thread using the obtained task parameters. The task parameters used for executing different threads may differ. This step can be implemented based on existing technology and will not be elaborated upon here.

[0077] Step 4: When creating a subtask during thread execution, store the task parameters of the created subtask in its corresponding first cache. Figure 3In the example of FIG. 1, processor core 1 creates subtask 1 in the process of executing thread 1, and processor core 1 stores the task parameters of subtask 1 to first cache 1. First cache is closer to processor core than second cache, and thus the access speed of first cache is faster and the power consumption of first cache is lower than that of second cache. In order to reduce the access times of second cache, the task parameters of subtask 1 do not need to be stored in second cache temporarily.

[0078] Step 5: A storage area is applied in second cache for storing the task parameters of the created subtask. Figure 3 In the example of FIG. 1, processor core 1 applies a storage area in second cache for storing the task parameters of subtask 1. Second cache is a cache shared by multiple processor cores, and the task parameters stored in second cache can be accessed by all processor cores.

[0079] The task scheduler can monitor the thread execution of each processor. When all the threads started by each processor core are executed completely, the task scheduler can start preparing for executing subtasks. The execution of subtasks requires the task parameters of subtasks, which are currently stored in each first cache and have storage areas in second cache for storing the task parameters. Thus, the task scheduler can notify each first cache to perform a flush operation to move the task parameters of subtasks stored in each first cache to second cache. The task parameters stored in each first cache have corresponding storage areas in second cache, and thus the task parameters can be moved to the corresponding storage areas. In the example of FIG. 1, the task scheduler notifies first cache 1 to move the task parameters of subtask 1 to second cache. Figure 3

[0080] After the task parameters are moved, the task scheduler can start scheduling subtasks to processor cores for execution. When a processor core receives a subtask, the processor core can access second cache to obtain the task parameters of the subtask and execute the subtask using the task parameters. In the example of FIG. 1, the task scheduler schedules subtask 1 to processor core N for execution, and processor core N receives subtask 1, accesses second cache to obtain the task parameters of subtask 1, and executes subtask 1 using the task parameters of subtask 1. Figure 3

[0081] If a new subtask is created in the execution of subtask 1, the task parameters can be stored in first cache and a storage area can be applied in second cache according to the above method of creating subtask 1. The above process can be repeated until all tasks are executed completely.

[0082] That is, the task parameters of subtasks can be transmitted between different processor cores through second cache, and the transmission of task parameters of subtasks through memory is avoided, which improves the transmission efficiency of task parameters and reduces the power consumption of task parameter transmission.​​

[0083] The GPU task creation system of the embodiments of the present disclosure schedules a new subtask created by executing a subtask creation consistent with the scheduling method of a subtask created by executing a parent task creation, and thus the system supports an arbitrary hierarchical relationship between a parent task and a subtask.

[0084] According to the GPU task creation system of the embodiments of the present disclosure, the GPU comprises a task scheduler, N processor cores, N first caches, and a second cache. The N first caches correspond to the N processor cores one by one, and N is a positive integer. The task scheduler schedules a task to be executed to at least one processor core for execution. Any processor core is configured to execute a received task, including starting at least one thread, obtaining task parameters of the received task, and executing a thread using the task parameters. When creating a subtask in the process of executing the thread, the task parameters of the subtask are stored in the first cache corresponding to the processor core. A storage area is applied for storing the task parameters of the subtask in the second cache. The task scheduler is configured to notify the first cache corresponding to each processor core to move the task parameters of the subtask to the corresponding storage area in the second cache when all the threads started by the processor core have been executed. When a processor core receives a subtask, the processor core accesses the second cache to obtain the task parameters of the subtask. The task parameters of the subtask are stored in the first cache corresponding to the processor core when the processor core creates the subtask, which makes the storage speed of the task parameters faster and improves the task execution efficiency of the processor core, thereby improving the working efficiency of the GPU. The task manager notifies the first cache corresponding to each processor core to move the task parameters to the second cache. The second cache is a cache shared by multiple processor cores, which ensures that each processor core can obtain the task parameters of the subtask when executing the subtask, so that the GPU task creation system can execute the subtask created by itself, which can improve the working efficiency of the GPU compared with waiting for the CPU to create the subtask. The task parameters are stored in the second cache instead of the memory, which makes the storage speed of the task parameters in the second cache and the speed of the processing module obtaining the task parameters faster, and the power consumption of moving the task parameters smaller. In summary, the GPU task creation system of the embodiments of the present disclosure can improve the working efficiency of the GPU and reduce the power consumption of the GPU.

[0085] In a possible implementation, the task scheduler is specifically configured to,

[0086] When preparing to schedule any task, at least one processor core is selected according to the total number of threads of the task, and the number of threads started by each selected processor core to execute the task is determined. The sum of the number of threads started by the selected at least one processor core to execute the task is equal to the total number of threads of the task.

[0087] When the task is scheduled to any processor core, the number of threads started by the processor core to execute the task is output to the processor core.

[0088] For example, the attribute information of each task (including the code address of the task, the total number of threads of the task, the dimension of the task, etc.) is written in advance and stored in a data structure. When the task scheduler is ready to schedule any task, the total number of threads of the task can be obtained, at least one processor core for executing the task is selected from the N processor cores according to the total number of threads of the task, and the number of threads started by each selected processor core for executing the task is determined. The sum of the number of threads started by each selected processor core for executing the task is equal to the total number of threads of the task. For example, the total number of threads of task 0 described above can be 30, and when only processor core 1 is selected to execute task 0, the total number of threads started by processor core 1 is equal to 30.

[0089] When the task is scheduled to any processor core, the task scheduler can output the number of threads started by the processor core for executing the task to the processor core. In this case, the processor core receiving the task can determine how many threads it needs to start.

[0090] In practical applications, due to the processing capability of the processor core, the processor core can not be able to start all the threads to be started at the same time. The processor core can start a part of the threads first, and after the part of the threads to be started are executed, new threads are continued to be started.

[0091] In a possible implementation, the task scheduler also counts the execution information of the subtasks to be executed, and the execution information indicates the execution times of the subtasks, and the storage area of the task parameters of each subtask in the second cache used when the subtask is executed each time;

[0092] Any processor core is also configured to transmit the creation information of the subtask to the task scheduler, and the creation information includes the pointer of the data structure of the subtask, the number of the storage area of the task parameters of the subtask in the second cache, and the execution times of the subtask.

[0093] The task scheduler is also configured to update the execution information of the subtask according to the creation information of the subtask, and when any subtask is scheduled to any processor core, the storage location of the task parameters of the subtask is output to the processor core according to the execution information of the subtask.

[0094] For example, the processor core is also configured to transmit the creation information of the subtask to the task scheduler, and the creation information includes the pointer of the data structure of the subtask, the number (or index) of the storage area of the task parameters of the subtask in the second cache, and the execution times of the subtask.

[0095] The pointer of the data structure of the task can point to the address of the data structure of the task. The task scheduler can obtain the data structure of the subtask according to the pointer of the data structure of the subtask. The addresses of the data structures of different tasks are different, and thus the pointers of the data structures of different tasks are different. The pointer of the data structure of the task can be used as the identifier of the task.

[0096] The number of the storage region of the task parameter of the subtask in the second cache can be the number of the storage region applied for the subtask by the processor core, and indicates the storage region of the task parameter in the cache module.

[0097] The execution times of the subtask represent how many times the current thread expects the subtask to be executed. The execution times are related to the number of the task parameters. If the number of the task parameters is 1, the subtask is expected to be executed once. If the number of the task parameters is 2, the subtask is expected to be executed twice, and the two executions use two task parameters respectively.

[0098] Those skilled in the art should understand that the creation information of the subtask can include more or less content, and the embodiments of the present disclosure do not limit the specific content of the creation information of the subtask.

[0099] The task scheduler also counts the execution information of the subtask to be executed. The execution information indicates the execution times of the subtask and the storage region of the task parameter in the second cache used when the subtask is executed each time. The task scheduler will continuously update the execution information according to the creation information of the subtask sent by the processor core. The embodiments of the present disclosure do not limit the content of the execution information, as long as the execution information can indicate the execution times of the subtask and the storage region of the task parameter in the second cache used when the subtask is executed each time. Exemplary contents included in the execution information are given below.

[0100] When any one of the subtasks is scheduled to any one of the processor cores, the task scheduler can output the storage location of the task parameter of the subtask to the processor core according to the execution information of the subtask. The processor core can access the received storage location to obtain the task parameter. Exemplary ways in which the task scheduler outputs the storage location are given below.

[0101] In this way, when the task scheduler schedules the subtask, the information required for executing the subtask can be output to the processor core more quickly, and the delay of the processor core in executing the task is reduced.

[0102] In a possible implementation, the GPU further includes a memory, the task parameters of the parent task are stored in the memory, and the task scheduler is further configured to,

[0103] When the parent task is scheduled to any one of the processor cores, the storage location of the task parameter of the parent task is output to the processor core.

[0104] The processor core is specifically configured to acquire the task parameter of the parent task according to the received storage location.

[0105] For example, as shown in Figure 2 When the CPU creates the parent task, the task parameter of the parent task can be stored in the memory. When the CPU sends the parent task to the GPU task creation system, the storage location of the task parameter of the parent task can also be sent to the GPU task creation system. In the GPU task creation system, when the task scheduler schedules the parent task to any one of the processor cores, the storage location of the task parameter of the parent task can be output to the processor core, and the storage location is located in the memory. The processor core can acquire the task parameter of the parent task by accessing the memory according to the received storage location.

[0106] It should be understood that the task parameter of the parent task can be stored in a continuous storage area in the memory, and therefore the storage location of the task parameter of the parent task output by the task scheduler to the processor core can only include the starting storage address and the parameter length of the task parameter of the parent task, or only include the starting storage address and the ending storage address of the task parameter of the parent task, or other information that can indicate a section of address. The task parameter of the child task is usually stored in a discrete form in the second cache, and in this case, the storage location of the task parameter of the child task output by the task scheduler to the processor core can include information indicating a plurality of sections of address. The embodiments of the present disclosure do not limit the specific content of the storage location of the task parameter of the parent task and the child task output by the task scheduler to the processor core.

[0107] In this way, when the task scheduler schedules the parent task / child task, the processor core is output with the information required to execute the task in a more flexible manner.

[0108] Figure 4 A schematic diagram showing the structure of the second cache according to an embodiment of the present disclosure.

[0109] As shown in Figure 4 In a possible implementation, the second cache includes a parameter storage space for data writing and a parameter storage space for data reading,

[0110] Any one of the processor cores is specifically configured to apply for a storage area in the parameter storage space for data writing;

[0111] The task scheduler is further configured to, after the first cache moves the task parameters of the to-be-executed subtask to the corresponding storage area in the second cache, change the parameter storage space used for data writing to the parameter storage space used for data reading, and change the parameter storage space used for data reading to the parameter storage space used for data writing; when the task scheduler schedules any one subtask to any one processor core, the storage location of the task parameters output to the processor core belongs to the parameter storage space used for data reading.

[0112] The processor core is specifically configured to access the parameter storage space used for data reading according to the received storage location to obtain the task parameters of the subtask.

[0113] For example, as described above, the processor core needs to access the second cache to read data when executing a task, and the task parameters of the subtask generated by the processor core when executing the task are also written to the second cache. If the second cache has only one storage space, and both data reading and data writing access the storage space, then read-write conflict will cause the access complexity of the second cache to be greatly increased, and the access efficiency of the second cache to be greatly reduced.

[0114] Therefore, as shown in FIG. 1, the second cache can include at least two kinds of parameter storage spaces, one of which is a parameter storage space used for data writing, and the other of which is a parameter storage space used for data reading. Figure 4

[0115] When the processor core executes a task, the task parameters are read from the storage space used for data reading. When a subtask is created during the execution of the task, a storage area used for storing the task parameters of the subtask can be applied for in the parameter storage space used for data writing, and the first cache moves the task parameters to the second cache, which is also moved to the parameter storage space used for data writing. As shown in FIG. 2, assuming that the parameter storage space used for data writing is FIFO1, the parameter storage space used for data reading is FIFO2, and the to-be-created subtask is subtask1, a storage area can be applied for in FIFO1 to store the task parameters of subtask1. Figure 4

[0116] ​​After the first cache moves the task parameters of the to-be-executed sub-tasks to the corresponding storage areas in the second cache, the task scheduler can start scheduling the to-be-executed sub-tasks. When the sub-tasks are executed, the task parameters need to be read from the second cache. If the sub-tasks are created when the sub-tasks are executed, a storage area needs to be applied for in the second cache, and the task parameters of the newly created sub-tasks will be written to the newly applied storage area. The task parameters that need to be read are currently stored in the storage space for data writing, and the task parameters in the storage space for data reading have been used up and are in an invalid state. Therefore, the parameter storage space for data writing can be changed to the parameter storage space for data reading, and the parameter storage space for data reading can be changed to the parameter storage space for data writing. As shown in FIG. 8, the function of FIFO1 can be changed to be used for data reading, and the function of FIFO2 can be changed to be used for data writing. Figure 4

[0117] In this case, when the task scheduler schedules any one of the sub-tasks to any one of the processor cores, the storage locations of the task parameters output to the processor core all belong to the parameter storage space for data reading.

[0118] The processor core can access the parameter storage space for data reading to obtain the task parameters of the sub-tasks according to the received storage locations. For example, the processor core can access FIFO1 for data reading to read out the task parameters of task 1 according to the received storage locations of the task parameters of task 1. Task 1 is executed to create sub-task 3, and a storage area is applied for sub-task 3 in FIFO2 for data writing. Subsequently, the first cache can move the task parameters of sub-task 3 to the storage area of the task parameters of sub-task 3 in FIFO2.

[0119] In this way, the GPU task creation system in the embodiments of the present disclosure can avoid the read-write conflict of the task parameters, reduce the access complexity of the second cache, and improve the access efficiency of the second cache.

[0120] An example of the execution information of the sub-tasks and the storage manner of the execution information of the sub-tasks is introduced below.

[0121] In a possible implementation manner, the task scheduler includes a first index table and a second index table, the second cache includes a third index table, the execution information of the sub-tasks includes a group of first execution information and a plurality of groups of second execution information, each group of second execution information corresponds to one execution of a sub-task,

[0122] ​The i-th entry of the first index table corresponds to the i-th subtask to be executed, and is used to store first execution information corresponding to the i-th subtask. The first execution information corresponding to the i-th subtask includes a pointer of a data structure of the i-th subtask, and a number of a storage area of second execution information corresponding to the first execution of the i-th subtask in the third index table. i is a positive integer.

[0123] The j-th entry of the second index table corresponds to the k-th execution of the i-th subtask to be executed, and is used to store second execution information corresponding to the k-th execution of the i-th subtask and a number of a storage area of the second execution information corresponding to the k-th execution of the i-th subtask in the third index table. The second execution information corresponding to the k-th execution of the i-th subtask includes a number of a storage area of a task parameter used by the i-th subtask in the k-th execution in the second cache, a length of the task parameter used by the i-th subtask in the k-th execution, and a number of a storage area of second execution information corresponding to the k+1-th execution of the i-th subtask in the third index table, and a number of subsequent executions of the i-th subtask. j and k are positive integers.

[0124] Figure 5 A schematic diagram showing a storage manner of execution information in a GPU task creation system according to an embodiment of the present disclosure is shown.

[0125] For example, as shown in Figure 5 In order to execute the subtasks more quickly, the first index table and the second index table can be set in the task scheduler. Considering that the storage resource of the task scheduler is limited, the third index table can be set in the second cache. The first index table can be used to find a storage area of a task parameter used when a subtask to be executed is executed for the first time. The second index table and the third index table can be used to find storage areas of all task parameters used when a subtask to be executed is executed. The data structures of the second index table and the third index table can be the same, and the second index table can be a "cache" of the third index table. The first index table, the second index table, and the third index table can be in software form.

[0126] The execution information of the subtask can include a group of first execution information and a plurality of groups of second execution information. The first execution information of the subtask is stored in the first index table, and indicates a storage area of second execution information corresponding to the first execution of the subtask. The second execution information of the subtask is stored in the second index table and the third index table, each group of second execution information corresponds to an execution of the subtask, and indicates a storage area of a task parameter used when the subtask is executed this time and a storage area of a task parameter used when the subtask is executed next time. It should be understood that if the resource of the second index table is sufficient, the storage area of the second execution information of the subtask can be applied for in the third index table only, and the second execution information of the subtask does not need to be actually stored in the third index table.

[0127] In one example, each entry of the first index table corresponds to one subtask to be executed. When the i-th entry of the first index table corresponds to the i-th subtask to be executed, a set of first execution information corresponding to the i-th subtask is stored, the set of first execution information corresponding to the i-th subtask includes a pointer of a data structure of the i-th subtask, and a number of a storage area of the second execution information corresponding to the first execution of the i-th subtask in the second cache, i is a positive integer.

[0128] Figure 6a An example of the first index table according to an embodiment of the present disclosure is shown. Figure 6b An example of the second index table according to an embodiment of the present disclosure is shown.

[0129] As shown, Figure 6a The first index table can include entries a1, a2, and so on. Each entry includes two fields, the first field stores a pointer of a data structure of a subtask, and the second field stores a number of a storage area of the second execution information corresponding to the first execution of the subtask in the third index table.

[0130] Entry a1 corresponds to subtask 0xbbbb, the first execution information of subtask 0xbbbb includes pointer 0xbbbb and number 13, indicating that the storage area of the second execution information corresponding to the first execution of subtask 0xbbbb in the third index table is the entry numbered 13. Entry a2 corresponds to subtask 0xcccc, the first execution information of subtask 0xcccc includes pointer 0xcccc and number 14, indicating that the storage area of the second execution information corresponding to the first execution of subtask 0xcccc in the third index table is the entry numbered 14.

[0131] In this case, when the task scheduler schedules the i-th subtask, an entry with the same pointer can be found in the first index table, and the number of the storage area of the second execution information corresponding to the first execution of the i-th subtask in the third index table is found in the entry.

[0132] In one example, each entry of the second index table corresponds to one execution of a subtask, and when the j-th entry of the second index table corresponds to the k-th execution of the i-th subtask to be executed, the second execution information corresponding to the k-th execution of the i-th subtask and the number of the storage area of the second execution information corresponding to the k-th execution of the i-th subtask in the third index table are stored. Therefore, according to the number of the storage area of the second execution information corresponding to the first execution of the i-th subtask in the third index table found in the first index table, the second execution information corresponding to the first execution of the i-th subtask can be found by searching the second index table.

[0133] The second execution information corresponding to the kth execution of the ith subtask includes a number of a storage area of the task parameter used by the kth execution of the ith subtask in the second cache in the third index table, a length of the task parameter used by the kth execution of the ith subtask, and a number of an entry corresponding to a (k+1)th execution of the ith subtask in the third index table, and a number of subsequent executions of the ith subtask, j and k are positive integers.

[0134] As shown in Figure 6b The second index table can include entries b1, b2, and the like. Each entry includes five fields, the first field stores a number of a storage area of the second execution information corresponding to the current execution of the subtask in the third index table. The second field stores a number of a storage area of the task parameter used by the current execution of the subtask in the second cache, the third field stores a length of the task parameter used by the current execution of the subtask, the fourth field stores a number of a storage area of the second execution information corresponding to the next execution of the subtask in the third index table, and the fifth field stores a number of subsequent executions of the subtask (also indicating the number of task parameters still needed to be used to execute the subtask).

[0135] Entry b1 corresponds to the 1st execution of subtask 0xbbbb, and includes a number 13 of a storage area of the second execution information corresponding to the current execution (1st execution) of subtask 0xbbbb in the third index table, a number 1235 of a storage area of the task parameter used by the current execution (1st execution) of subtask 0xbbbb in the second cache, a length 5 of the task parameter used by the current execution (1st execution) of subtask 0xbbbb, a number 0 of a storage area of the second execution information corresponding to the next execution (2nd execution) of subtask 0xbbbb in the third index table (0 is an identifier indicating invalid, that is, subtask 0xbbbb is executed only once), and a number 1 of subsequent executions of subtask 0xbbbb (including the current execution).

[0136] Entry b2 corresponds to the 1st execution of subtask 0xcccc, and includes a number 14 of a storage area of the second execution information corresponding to the current execution (1st execution) of subtask 0xcccc in the third index table, a number 1233 of a storage area of the task parameter used by the current execution (1st execution) of subtask 0xcccc in the second cache, a length 5 of the task parameter used by the current execution (1st execution) of subtask 0xcccc, a number 0 of a storage area of the second execution information corresponding to the next execution (2nd execution) of subtask 0xcccc in the third index table (0 is an identifier indicating invalid, that is, subtask 0xcccc is executed only once), and a number 1 of subsequent executions of subtask 0xcccc (including the current execution).

[0137] In this case, when the task scheduler schedules the i-th subtask, the second execution information corresponding to the first execution of the i-th subtask is determined according to the second index table, the storage area of the task parameter used by the first execution of the i-th subtask in the second cache is determined, and according to the length of the task parameter used by the first execution of the i-th subtask, it is determined how long a piece of data needs to be read when reading the task parameter. According to the number of subsequent executions of the i-th subtask, it is determined whether it is necessary to continue to search the second index table. When the number of subsequent executions is greater than 1, the second index table is searched according to the number of the entry corresponding to the second execution of the i-th subtask in the third index table, and the second execution information corresponding to the second execution of the i-th subtask is found. In this way, the task scheduler can determine the number of executions of the i-th subtask and the storage location of the task parameter used by each execution. The task scheduler can send the storage location of the task parameter used by each execution of the i-th subtask (for example, the number of the entry storing the task parameter in the second cache and the length of the task parameter) to the processor core selected to execute the i-th subtask.

[0138] The second index table is located in the task scheduler, and therefore the capacity can be small. When the second index table is full, some entries can be moved out to the third index table. The task scheduler searches the second index table faster than the third index table, and therefore the second index table can be searched first. If the corresponding entry cannot be found in the second index table, the third index table is searched. As long as the execution information of the subtask can be stored in the GPU, the specific storage location of the execution information of the subtask is not limited in the embodiments of the present disclosure.

[0139] The execution information of the subtask can include more or less content, and the specific content of the execution information of the subtask is not limited in the art.

[0140] In this way, the task scheduler of the embodiments of the present disclosure can determine how many times the subtask needs to be executed and the storage location of the task parameter used by each execution when the subtask is executed, so as to improve the work efficiency of the GPU.

[0141] The following describes an exemplary way of updating the execution information of the subtask according to the creation information of the subtask.

[0142] In a possible implementation, the task scheduler is specifically configured to:

[0143] According to the creation information of the subtask, it is determined whether the execution information of the same subtask has been stored in the task scheduler.

[0144] When the execution information of the same subtask is not stored in the task scheduler, selecting an entry from the first index table for storing the first execution information corresponding to the subtask, and selecting an entry from the second index table for storing the second execution information corresponding to the subtask;

[0145] applying an entry in the third index table for storing the second execution information corresponding to the subtask;

[0146] writing the pointer of the data structure of the subtask into the selected entry in the first index table;

[0147] writing the number of the applied entry in the third index table as the number of the storage area of the second execution information corresponding to the first execution of the subtask in the third index table into the selected entries in the first index table and the second index table;

[0148] writing the number included in the creation information as the number of the storage area of the task parameter used by the subtask in the first execution in the second cache into the selected entry in the second index table;

[0149] writing the length of the task parameter of the subtask as the length of the task parameter used by the subtask in the first execution into the selected entry in the second index table;

[0150] writing an invalid identifier as the number of the entry in the third index table corresponding to the second execution of the subtask into the selected entry in the second index table;

[0151] writing 1 as the number of subsequent executions of the subtask into the selected entry in the second index table.

[0152] For example, a processor core executes multiple threads, and a subtask created by a certain thread can be a subtask that has not been created by other previously executed threads, or can be a subtask that has been created by other previously executed threads. If the same subtask has been created by other previously executed threads, the execution information of the same subtask can be stored in the task scheduler.

[0153] Therefore, whether the execution information of the same subtask is stored in the task scheduler can be queried according to the creation information of the subtask.

[0154] In a possible implementation, the task scheduler is specifically used for:

[0155] querying whether the pointer included in the creation information is stored in the first index table;

[0156] when the pointer included in the creation information is stored in the first index table, determining that the execution information of the same subtask is stored in the task scheduler;

[0157] When the first index table does not store the pointer included in the creation information, it is determined that the execution information of the same subtask is not stored in the task scheduler.

[0158] For example, if the execution information of the same subtask is stored in the task scheduler, the pointer included in the creation information of the subtask is stored in the first index table.

[0159] Therefore, it can be queried whether the pointer included in the creation information is stored in the first index table. If the pointer included in the creation information is stored in the first index table, it is determined that the execution information of the same subtask is stored in the task scheduler; otherwise, it is determined that the execution information of the same subtask is not stored in the task scheduler.

[0160] If the execution information of the same subtask is not stored in the task scheduler, an entry can be selected from the first index table for storing a set of first execution information corresponding to the subtask, an entry can be selected from the second index table for storing a set of second execution information corresponding to the subtask. At this time, the selected entry in the first index table corresponds to the subtask, and the selected entry in the second index table corresponds to the first execution of the subtask. An entry is applied for in the third index table for storing a set of second execution information corresponding to the subtask. At this time, the applied entry in the third index table corresponds to the first execution of the subtask. Figure 7a A schematic diagram showing the updated first index table according to an embodiment of the present disclosure is shown. Figure 7b A schematic diagram showing the updated second index table according to an embodiment of the present disclosure is shown.

[0161] For example, it is assumed that the creation information of the created subtask includes the pointer 0xdddd, the number 1241 of the storage area of the task parameter of the subtask in the second cache, and the execution number 1 of the subtask.

[0162] After the task scheduler queries the first index table, it is determined that the first index table does not store the task information of the subtask 0xdddd, and then entries can be selected from the first index table and the second index table, and an entry can be applied for in the third index table. It is assumed that the entry a3 is selected from the first index table, the entry b3 is selected from the second index table, and the entry 15 is applied for in the third index table.

[0163] The pointer of the data structure of the subtask can be written in the selected entry in the first index table. For example, as shown in Figure 7a the pointer 0xdddd can be written in the first field of the entry a3.

[0164] The number of the applied entry in the third index table can be written in the selected entries in the first index table and the second index table as the number of the storage area of the second execution information corresponding to the first execution of the subtask in the third index table. For example, as shown in Figure 7aAs shown, the number 15 can be written into the second field of the entry a3. Figure 7b As shown, the number 15 can be written into the first field of the entry b3.

[0165] The number of the storage area of the task parameter of the subtask in the second cache, as the number of the storage area of the task parameter used by the first execution of the subtask in the second cache, can be written into the selected entry in the second index table. For example, as shown, the number 1241 can be written into the second field of the entry b3. Figure 7b

[0166] The length of the task parameter of the subtask, as the length of the task parameter used by the first execution of the subtask, can be written into the selected entry in the second index table. For example, as shown, the length 1 can be written into the third field of the entry b3. Figure 7b

[0167] The identification (for example, 0) indicating invalidity, as the number of the entry in the third index table corresponding to the second execution of the subtask, can be written into the selected entry in the second index table. For example, as shown, 0 can be written into the fourth field of the entry b3. Figure 7b

[0168] 1 can be written into the selected entry in the second index table as the number of subsequent executions of the subtask. In the embodiment of the present disclosure, the subsequent execution includes the current execution. For example, as shown, 1 can be written into the fifth field of the entry b3. Figure 7b

[0169] In this case, the entry a3 corresponds to the subtask 0xdddd, and the entry b3 corresponds to the first execution of the subtask 0xdddd.

[0170] In this way, the update of the execution information of the subtask is completed in the case that the task scheduler does not store the execution information of the subtask to be created.

[0171] In a possible implementation, the task scheduler is specifically used for:

[0172] According to the creation information of the subtask, it is queried whether the execution information of the same subtask has been stored in the task scheduler;

[0173] When the execution information of the same subtask is stored in the task scheduler, and the same subtask is the i-th subtask,

[0174] ​​​​query the second index table and / or the third index table to determine all second execution information corresponding to the previous x executions of the ith subtask, when any one set of second execution information meets the first condition, add the length of the task parameter of the subtask to the length of the task parameter included in the second execution information, and add the execution number of the subtask to the subsequent execution number of the subtask included in the second execution information; x is the smaller one of the second value and the total execution number of the ith subtask, and x is a positive integer;

[0175] The first condition is that the sum of the number of the storage area of the task parameter in the second cache used by the execution corresponding to the second execution information and the length of the task parameter is equal to the number included in the creation information.

[0176] For example, if the execution information of the same subtask is stored in the task scheduler, and the storage area of the task parameter in the second cache used by a certain execution of the same subtask is continuous with the storage area of the task parameter of the subtask to be created in the second cache, a new entry does not need to be applied or selected, and the information recorded in the second execution information of the corresponding execution of the same subtask can be modified slightly.

[0177] For example, assuming that the same subtask found is the ith subtask to be executed. Then, by querying the second index table and / or the third index table, all second execution information corresponding to the previous x executions of the ith subtask can be determined. x is the smaller one of the second value and the total execution number of the ith subtask, and x is a positive integer. The second value can be set in advance according to the query depth required by the application scenario, and the embodiments of the present disclosure do not limit the second value. The total execution number of the ith subtask can be the subsequent execution number recorded in the second execution information corresponding to the first execution of the ith subtask.

[0178] For example, the first index table and the second index table are as shown in Figure 7a and Figure 7b Assuming that the creation information of the newly created subtask includes the pointer 0xbbbb, the number 1240 of the storage area of the task parameter of the subtask in the second cache, and the execution number 1 of the subtask. By querying the second index table, it can be determined that the total execution number of the subtask 0xbbbb is 1, and assuming that the second value is 10, x can be equal to 1. All second execution information corresponding to the previous 1 executions of the subtask 0xbbbb can be stored in the entry b1 as shown in Figure 7b

[0179] ​It can be determined whether a set of second execution information satisfies the first condition. The first condition can be that the sum of the number of the storage area of the task parameter used in the one execution corresponding to the second execution information in the second cache and the length of the task parameter is equal to the number included in the creation information. At this time, the storage area of the task parameter corresponding to the set of second execution information in the second cache and the storage area of the task parameter corresponding to the creation information in the second cache are continuous.

[0180] For example, as shown in FIG. 1B, the number of the storage area of the task parameter used in the one execution corresponding to the second execution information stored in the entry b1 in the second cache, that is, the number stored in the second field of the entry b1, is 1235. The length of the task parameter is 5. The sum of the two is equal to the number 1240 included in the creation information. Therefore, the second execution information stored in the entry b1 satisfies the first condition. Figure 7b

[0181] When the second execution information stored in any one entry satisfies the first condition, the length of the task parameter of the subtask included in the creation information is added to the length of the task parameter stored in the entry, and the execution number of the subtask is added to the subsequent execution number of the subtask stored in the entry. The first index table does not need to be updated.

[0182] Figure 8 A schematic diagram showing the second index table updated according to an embodiment of the present disclosure is shown.

[0183] For example, as shown in FIG. 1B, the number of the storage area of the task parameter used in the one execution corresponding to the second execution information stored in the entry b1 in the second cache, that is, the number stored in the second field of the entry b1, is 1235. The length of the task parameter is 5. The sum of the two is equal to the number 1240 included in the creation information. Therefore, the second execution information stored in the entry b1 satisfies the first condition. Figure 7b Figure 8 As shown in FIG. 1B, the length of the task parameter determined by the current creation of the subtask 0xbbbb can be added to the length 5 stored in the entry b1, so that the length stored in the entry b1 is updated to 6. The execution number 1 of the subtask included in the creation information is added to the subsequent execution number 1 of the subtask stored in the entry b1, so that the subsequent execution number of the subtask stored in the entry b1 is updated to 2.

[0184] In this way, in the case that the task scheduler stores the execution information of the subtask to be created, the update of the execution information of the subtask can be completed without allocating a new entry of the second index table for the subtask, so that the storage resource of the second index table can be saved.

[0185] In a possible implementation, the first execution of the i th subtask corresponds to the p th entry in the second index table, p is a positive integer, and the task scheduler is specifically configured to:

[0186] When there is no entry satisfying the first condition, an entry is selected from the second index table, which is used to store a set of second execution information corresponding to the i th subtask.

[0187] ​​an entry in the third index table is applied to store a group of second execution information corresponding to the i-th subtask;

[0188] the number of the entry applied in the third index table is written in the selected entry in the second index table as the number of the storage area of the third index table in which the second execution information corresponding to the first execution of the i-th subtask is stored;

[0189] the number included in the creation information is written in the selected entry in the second index table as the number of the storage area of the second cache in which the task parameter used by the i-th subtask in the first execution is stored;

[0190] the length of the task parameter of the subtask is written in the selected entry in the second index table as the length of the task parameter used by the i-th subtask in the first execution;

[0191] the number stored in the entry corresponding to the i-th subtask in the first index table is written in the selected entry in the second index table as the number of the entry in the third index table corresponding to the second execution of the i-th subtask;

[0192] the number of the subsequent execution stored in the p-th entry is added to the number of the execution of the subtask as the number of the subsequent execution of the i-th subtask, which is written in the selected entry in the second index table;

[0193] the number stored in the entry corresponding to the i-th subtask in the first index table is updated to the number of the entry applied in the third index table.

[0194] For example, if none of the x groups of second execution information satisfies the first condition, it can be considered that a new entry is needed to store a new group of second execution information.

[0195] In this case, an entry can be selected from the second index table to store a group of second execution information corresponding to the i-th subtask, and an entry is applied in the third index table to store a group of second execution information corresponding to the i-th subtask.

[0196] For example, the first index table and the second index table are as shown in Figure 7a and Figure 8 Assuming that the creation information of the newly created subtask includes the pointer 0xcccc, the number of the storage area of the task parameter of the subtask in the second cache is 1245, and the number of the execution of the subtask is 1, the total number of the execution of the subtask 0xcccc can be determined to be 1 by querying the second index table, and assuming that the second value is 10, x can be equal to 1. All the second execution information corresponding to the first execution of the subtask 0xcccc can be stored in the entry b2.

[0197] If the task scheduler determines that the second execution information stored in entry b2 does not satisfy the first condition, it can select an entry from the second index table and apply for an entry from the third index table. Assume that entry b4 is selected from the second index table and entry 16 is applied for from the third index table.

[0198] It should be understood that the selected entry in the second index table and the applied entry in the third index table correspond to the first execution of the ithsubtask, and the execution information of the subtask to be executed needs the least update. In this case, the entry in the second index table corresponding to the ythexecution (y is a positive integer) of the ithsubtask does not need to be updated and automatically becomes the entry corresponding to the (y+1)thexecution of the ithsubtask.

[0199] Figure 9a A schematic diagram showing the updated first index table according to an embodiment of the present disclosure is shown. Figure 9b A schematic diagram showing the updated second index table according to an embodiment of the present disclosure is shown.

[0200] The number of the applied entry in the third index table can be written into the selected entry in the second index table as the number of the storage area of the second execution information corresponding to the first execution of the ithsubtask in the third index table. For example, as shown in Figure 9b , the number 16 can be written into the first field of entry b4.

[0201] The number included in the creation information can be written into the selected entry in the second index table as the number of the storage area of the task parameter used by the ithsubtask in the first execution in the cache module. For example, as shown in Figure 9b , the number 1245 can be written into the second field of entry b4.

[0202] The length of the task parameter of the subtask included in the creation information can be written into the selected entry in the second index table as the length of the task parameter used by the ithsubtask in the first execution.

[0203] For example, as shown in Figure 9b , the length of the task parameter of the subtask 1 can be written into the third field of entry b4.

[0204] The number stored in the entry corresponding to the ithsubtask in the first index table can be written into the selected entry in the second index table as the number of the entry corresponding to the second execution of the ithsubtask in the third index table. For example, the number 14 stored in entry a2 (see Figure 7a ) can be written into the fourth field of entry b4 (see Figure 9b ).

[0205] The cumulative creation information includes the execution times of the subtasks and the subsequent execution times stored in the pth entry, as the subsequent execution times of the ith subtask, written in the selected entry in the second index table.

[0206] For example, the pth entry can be entry b2, the cumulative creation information includes the execution times 1 of the subtasks and the subsequent execution times 1 stored in entry b2, the result of the accumulation is 2, written in the fifth field of entry b4.

[0207] Since the entry applied in the third index table has corresponded to the 1st execution of the ith subtask, the number stored in the entry corresponding to the ith subtask in the first index table can be updated to the number of the entry applied in the third index table. For example, as shown in Figure 9a the number stored in entry a2 can be updated to 16.

[0208] In this way, the update of the execution information of the subtasks can be completed in the case that the task scheduler stores the execution information of the subtasks to be created.

[0209] The exemplary structures of the first index table, the second index table and the third index table are described below. Figure 10 The schematic diagram showing the structures of the first index table, the second index table and the third index table according to the embodiments of the present disclosure is shown.

[0210] In a possible implementation, the first index table, the second index table and the third index table respectively include a linked list for data writing and a linked list for data reading,

[0211] The task scheduler is specifically configured to, when selecting entries from the first index table and the second index table, select entries from the linked list for data writing; and when applying entries from the third index table, apply entries from the linked list for data writing.

[0212] The task scheduler is further configured to, after notifying each processor core to move the task parameters of the subtasks to be executed from the corresponding first cache to the corresponding storage area in the second cache, change the linked list for data writing to the linked list for data reading, and change the linked list for data reading to the linked list for data writing; and the task scheduler is specifically configured to, when querying the first index table, the second index table and the third index table, query the linked list for data reading.

[0213] For example, since the information stored in the first index table, the second index table and the third index table also needs to be frequently written and read, to avoid read-write conflicts, the first index table, the second index table and the third index table can respectively include a linked list for data writing and a linked list for data reading. For example, Figure 10As shown, the first index table includes the linked list LIST10 for data writing and the linked list LIST11 for data reading, and the linked list LIST10 for data reading and the linked list LIST11 for data writing. The second index table includes the linked list LIST20 for data writing and the linked list LIST21 for data reading, and the linked list LIST20 for data reading and the linked list LIST21 for data writing. The third index table includes the linked list LIST30 for data writing and the linked list LIST31 for data reading, and the linked list LIST30 for data reading and the linked list LIST31 for data writing.

[0214] When the task scheduler selects an entry from the first index table and the second index table, since data needs to be written into the selected entry, the entry can be selected from the linked list for data writing. When the task scheduler applies for an entry from the third index table, since data may need to be written into the applied entry later, the entry can be applied from the linked list for data writing.

[0215] After the task scheduler notifies each processor core to move the task parameters of the subtask to be executed to the corresponding storage area in the second cache of the corresponding first cache, the task scheduler needs to query the first index table, the second index table and the third index table to determine how to execute the subtask. The query of the first index table, the second index table and the third index table is a data reading operation, so the linked list for data writing can be changed to the linked list for data reading, and the linked list for data reading can be changed to the linked list for data writing. The way of changing the data writing, the data reading and the function of the linked list is similar to the way of changing the data writing, the data reading and the function of the parameter storage space in the related description of Figure 4 and will not be described here.

[0216] In this way, the GPU task creation system of the embodiments of the present disclosure can avoid the read-write conflict of execution information.

[0217] Since the storage location of the task parameters used each time the subtask is executed is recorded in the form of a linked list, and the linked list can be lengthened to any length under the condition of sufficient resources, the GPU task creation system of the embodiments of the present disclosure supports any ratio of task parameters and threads.

[0218] In a possible implementation, the task to be executed includes a parent task created by the CPU and a system-created to-be-executed child task, and the task scheduler is further configured to: count a first thread number, the first thread number being a total number of threads of the system-created to-be-executed child task; when the first thread number reaches a first value, notify a processor core executing the parent task to stop executing the parent task and start scheduling the system-created to-be-executed child task to at least one processor core for execution, the first value being a product of the maximum number of threads executed in parallel by the GPU and the saturation ratio; and when the first thread number is less than the first value, notify the processor core executing the parent task to continue executing the parent task.

[0219] For example, all task parameters of the to-be-executed child task need to be stored in the GPU, and the more task parameters of the to-be-executed child task, the greater the storage pressure of the GPU. The parallel execution capability of the GPU is limited, and if the total number of threads of the to-be-executed child task has exceeded the parallel execution capability of the GPU, part of the task parameters stored may not be used in a short time, which wastes the storage resources of the GPU. The capacity of the second cache is also limited, and if more task parameters cannot be stored, the memory needs to be used to store the task parameters, which leads to the decrease of the working efficiency of the GPU and the increase of the power consumption.

[0220] To this end, the first value can be determined according to the product of the maximum number of threads executed in parallel by the GPU and the saturation ratio, and the first value can represent the upper limit of the parallel execution capability of the GPU. The task scheduler can count the first thread number, the first thread number being the total number of threads of the system-created to-be-executed child task, and it should be noted that the executed child task does not need to participate in the counting. If the first thread number reaches the first value, the processor core executing the parent task can be notified to stop executing the parent task and start scheduling the system-created to-be-executed child task to at least one processor core for execution. The task scheduler can record the total number of started threads, and after determining that all the started threads have been executed, the to-be-executed child task can be scheduled.

[0221] The saturation ratio can be set according to the demand of the application scenario, and can be set to a value between 1 and 2. The specific value of the saturation ratio is not limited in the embodiments of the present disclosure.

[0222] With the execution of the to-be-executed child task, the first thread number can decrease. When the first thread number is less than the first value, the parent task can be continued, where the parent task can continue to generate threads, and when the first thread number reaches the first value again, the parent task can be stopped again. The stopping and continuing of the parent task can be cyclically repeated until the parent task is executed.

[0223] In this case, the number of started threads can be guaranteed to reach the upper limit of the parallel execution capability of the GPU each time the parent task is executed, and the utilization of the GPU can be maximized.

[0224] The second index table has a limited capacity, so when selecting an entry from the second index table, if there is no free entry in the second index table, a stored entry with the minimum number of subsequent executions can be selected from the second index table, and the second execution information corresponding to the entry is used with the minimum probability. The data included in the entry can be moved to the corresponding entry in the third index table, and the entry is selected as the selected entry.

[0225] If the corresponding entry is not found in the second index table, the third index table can be accessed to find the corresponding entry, and the data of the found entry is loaded into the second index table. The subsequent operation is the same as the operation performed after the entry is found in the second index table, which will not be repeated here.

[0226] The execution process of the subtask to be executed will not be interrupted. That is, if the total number of threads executing the new subtask created by the subtask reaches the first value, the execution of the subtask will not be stopped.

[0227] An example of the overall process of the GPU task creation system from the start of the parent task to the completion of the parent task execution is given below.

[0228] First, in the GPU task creation system, the task scheduler receives the parent task (such as task 0) from the CPU, and the storage location of the task parameters of the parent task in the memory.

[0229] The task scheduler obtains the attribute information of the parent task according to the pointer carried by the parent task, determines at least one processor core for executing the parent task according to the attribute information of the parent task, and determines the number of threads to be started by each processor core for executing the parent task.

[0230] The task scheduler can schedule the parent task to the determined processor core for execution. At the same time, the task scheduler also outputs the number of threads to be started by the processor core for executing the parent task and the storage location of the task parameters of the parent task in the memory to the processor core.

[0231] After any one processor core receives the parent task, the number of threads, and the storage location of the task parameters of the parent task in the memory, it accesses the memory to obtain the task parameters of the parent task, starts threads according to the received number of threads, and executes the threads using the task parameters of the parent task.

[0232] After the parent task is executed for a period of time, the execution information of the subtask in the task scheduler can be referred to Figure 6a and Figure 6b .

[0233] When any one thread needs to create subtask 0xdddd during the execution process, the task parameters of subtask 0xdddd can be stored in the first cache corresponding to the current processor core.

[0234] A task parameter storage area (e.g., entry numbered 1241) can be applied for in the second cache, and the creation information of the subtask (including the pointer 0xdddd of the data structure of the subtask, the number 1241 of the storage area applied for in the second cache, and the number 1 of the task parameters of the subtask) is sent to the task scheduler.

[0235] Upon receiving the creation information of the subtask 0xdddd, the task scheduler can update the execution information of the subtask 0xdddd. The statistics of the updated execution information can be seen from Figure 7a and Figure 7b .

[0236] When the subtask 0xbbbb needs to be created in the execution process of any thread, the task parameters of the subtask 0xbbbb can be stored in the first cache corresponding to the current processor core. A task parameter storage area (e.g., entry numbered 1240) can be applied for in the second cache, and the creation information of the subtask (including the pointer 0xbbbb of the data structure of the subtask, the number 1240 of the storage area applied for in the second cache, and the number 1 of the task parameters of the subtask) is sent to the task scheduler.

[0237] Upon receiving the creation information of the subtask 0xbbbb, the task scheduler can update the execution information of the subtask 0xbbbb. The statistics of the updated execution information can be seen from Figure 7a and Figure 8 .

[0238] When the subtask 0xcccc needs to be created in the execution process of any thread, the task parameters of the subtask 0xcccc can be stored in the first cache corresponding to the current processor core. A task parameter storage area (e.g., entry numbered 1245) can be applied for in the second cache, and the creation information of the subtask (including the pointer 0xcccc of the data structure of the subtask, the number 1245 of the storage area applied for in the second cache, and the number 1 of the task parameters of the subtask) is sent to the task scheduler.

[0239] Upon receiving the creation information of the subtask 0xcccc, the task scheduler can update the execution information of the subtask 0xcccc. The statistics of the updated execution information can be seen from Figure 9a and Figure 9b .

[0240] If the number of the first threads reaches the first value at this time, the task manager can notify each processor core to stop executing the parent task (stop starting the thread of the parent task) and notify each first cache to move the stored task parameters to the second cache.

[0241] After the task parameters are moved, the task scheduler can update the execution information of the parent task according to Figure 9a and Figure 9bThe execution information of the illustrated sub-tasks schedules the sub-tasks. For example, the task scheduler schedules the sub-tasks 0xbbbb, 0xcccc, and 0xdddd in turn. When the first thread number is detected to be less than the first value, the task scheduler informs each processor core to continue executing the parent task (continue to start the thread of the parent task). The above process of stopping executing the parent task, scheduling the sub-tasks, and continuing to execute the parent task is repeated until all threads of the parent task and all threads of the sub-tasks are executed.

[0242] The GPU task creation method according to the embodiments of the present disclosure is shown in the flowchart. Figure 11 The GPU task creation method according to the embodiments of the present disclosure is shown in the flowchart.

[0243] As Figure 11 In a possible implementation, the method is performed by a GPU task creation system, the system is arranged in a GPU, the system includes a task scheduler, N processor cores, N first caches, and a second cache, the N first caches correspond to the N processor cores one by one, the second cache is shared by the N processor cores, and N is a positive integer; and the method includes the following steps.

[0244] In step S31, the task scheduler is used to schedule a task to be executed to at least one processor core for execution.

[0245] In step S32, any one processor core is used to execute the received task, including starting at least one thread, obtaining the task parameters of the received task, executing the thread using the task parameters, storing the task parameters of the sub-task to the first cache corresponding to the processor core when the sub-task is created during the execution of the thread, and applying a storage area in the second cache for storing the task parameters of the sub-task.

[0246] In step S33, the task scheduler is used to inform the first cache corresponding to each processor core to move the task parameters of the sub-task to the corresponding storage area in the second cache when all the threads started by each processor core are executed, and the processor core accesses the second cache to obtain the task parameters of the sub-task when the sub-task is received.

[0247] In a possible implementation, the task to be executed includes a parent task created by a CPU and a to-be-executed child task created by the system, and the method further includes: using the task scheduler to further count a first thread number, the first thread number being a total number of threads of the to-be-executed child task created by the system; when the first thread number reaches a first value, using the task scheduler to notify a processor core executing the parent task to stop executing the parent task and start scheduling the to-be-executed child task created by the system to at least one processor core for execution, the first value being a product of the maximum number of threads executed in parallel by the GPU and a saturation ratio; when the first thread number is less than the first value, using the task scheduler to notify the processor core executing the parent task to continue executing the parent task.

[0248] In a possible implementation, the method further includes: using the task scheduler to count execution information of the to-be-executed child task, the execution information indicating a number of times of execution of the child task, and a storage area of the task parameter of the child task in the second cache each time the child task is executed; using the task scheduler to transmit, to the task scheduler, creation information of the child task, the creation information including a pointer of a data structure of the child task, a number of the storage area of the task parameter of the child task in the second cache, and the number of times of execution of the child task; using the task scheduler to update the execution information of the child task according to the creation information of the child task; and using the task scheduler to output, to the processor core, a storage location of the task parameter of the child task according to the execution information of the child task when scheduling any child task to any processor core.

[0249] In a possible implementation, the second cache includes a parameter storage space for data writing and a parameter storage space for data reading, and the method further includes: applying for a storage area in the parameter storage space for data writing; and after the first cache moves the task parameter of the to-be-executed child task to the corresponding storage area in the second cache, using the task scheduler to change the parameter storage space for data writing to the parameter storage space for data reading, and change the parameter storage space for data reading to the parameter storage space for data writing; when the task scheduler schedules any child task to any processor core, the task scheduler outputs, to the processor core, a storage location of the task parameter belonging to the parameter storage space for data reading; and when the processor core receives the child task, the processor core accesses the second cache to obtain the task parameter of the child task, including: the processor core accesses the parameter storage space for data reading according to the received storage location to obtain the task parameter of the child task.

[0250] In a possible implementation, the task scheduler comprises a first index table and a second index table, the second cache comprises a third index table, the execution information of the subtask comprises a first execution information and a plurality of second execution information, each second execution information corresponds to an execution of the subtask, an i-th entry of the first index table corresponds to an i-th subtask to be executed, and is used to store first execution information corresponding to the i-th subtask, the first execution information corresponding to the i-th subtask comprises a pointer of a data structure of the i-th subtask, and a storage area number of second execution information corresponding to a first execution of the i-th subtask in the third index table, i is a positive integer; a j-th entry of the second index table corresponds to a k-th execution of the i-th subtask to be executed, and is used to store second execution information corresponding to the k-th execution of the i-th subtask and a storage area number of the second execution information corresponding to the k-th execution of the i-th subtask in the third index table, the second execution information corresponding to the k-th execution of the i-th subtask comprises a storage area number of a task parameter used by the i-th subtask in the k-th execution in the second cache, a length of the task parameter used by the i-th subtask in the k-th execution, a storage area number of second execution information corresponding to a k+1-th execution of the i-th subtask in the third index table, and a subsequent execution number of the i-th subtask, j and k are positive integers.

[0251] In a possible implementation, the updating the execution information of the subtask according to the creation information of the subtask comprises: querying whether the execution information of the same subtask has been stored in the task scheduler according to the creation information of the subtask; when the execution information of the same subtask has not been stored in the task scheduler, selecting an entry from the first index table for storing the first execution information corresponding to the subtask, selecting an entry from the second index table for storing the second execution information corresponding to the subtask, and applying an entry in the third index table for storing the second execution information corresponding to the subtask; writing the pointer of the data structure of the subtask into the selected entry in the first index table, writing the number of the applied entry in the third index table as the number of the storage area of the second execution information corresponding to the first execution of the subtask in the third index table into the selected entries in the first index table and the second index table, writing the number included in the creation information as the number of the storage area of the task parameter used in the first execution of the subtask in the second cache into the selected entry in the second index table, writing the length of the task parameter of the subtask as the length of the task parameter used in the first execution of the subtask into the selected entry in the second index table, and writing the invalid identifier as the number of the entry corresponding to the second execution of the subtask in the third index table into the selected entry in the second index table; and writing 1 as the number of subsequent executions of the subtask into the selected entry in the second index table.

[0252] In a possible implementation, the updating the execution information of the subtask according to the creation information of the subtask comprises: querying whether the execution information of the same subtask has been stored in the task scheduler according to the creation information of the subtask; when the execution information of the same subtask has been stored in the task scheduler, and the same subtask is the ith subtask, querying the second index table and / or the third index table to determine all the second execution information corresponding to the first x executions of the ith subtask, and when any one of the second execution information satisfies a first condition, adding the length of the task parameter of the subtask to the length of the task parameter included in the second execution information, and adding the number of executions of the subtask to the number of subsequent executions of the subtask included in the second execution information; x is the smaller one of a second value and the total number of executions of the ith subtask, and x is a positive integer; and the first condition is that the sum of the number of the storage area of the task parameter used in the execution corresponding to the second execution information in the second cache and the length of the task parameter is equal to the number included in the creation information.

[0253] In a possible implementation, the first execution of the ith subtask corresponds to the pth entry in the second index table, p is a positive integer, and the updating of the execution information of the subtask according to the creation information of the subtask includes: when there is no entry satisfying the first condition, selecting an entry from the second index table to store a set of second execution information corresponding to the ith subtask; applying an entry in the third index table to store a set of second execution information corresponding to the ith subtask; writing, in the selected entry in the second index table, a number of the applied entry in the third index table as a number of a storage area of the third index table corresponding to the second execution information corresponding to the first execution of the ith subtask; writing, in the selected entry in the second index table, a number included in the creation information as a number of a storage area of the second cache corresponding to the task parameter used by the first execution of the ith subtask; writing, in the selected entry in the second index table, a length of the task parameter of the subtask as a length of the task parameter used by the first execution of the ith subtask; writing, in the selected entry in the second index table, a number stored in the entry corresponding to the ith subtask in the first index table as a number of the entry corresponding to the second execution of the ith subtask in the third index table; writing, in the selected entry in the second index table, a sum of the execution times of the subtask and the subsequent execution times stored in the pth entry as the subsequent execution times of the ith subtask; and updating the number stored in the entry corresponding to the ith subtask in the first index table to the number of the applied entry in the third index table.

[0254] In a possible implementation, the querying of whether the execution information of the same subtask has been stored in the task scheduler according to the creation information of the subtask includes: querying whether the first index table has stored the pointer included in the creation information; determining that the execution information of the same subtask has been stored in the task scheduler when the first index table has stored the pointer included in the creation information; and determining that the execution information of the same subtask has not been stored in the task scheduler when the first index table has not stored the pointer included in the creation information.

[0255] In a possible implementation, the first index table, the second index table and the third index table respectively include a linked list for data writing and a linked list for data reading, the task scheduler selects an entry from the linked list for data writing when selecting an entry from the first index table and the second index table, and applies an entry from the linked list for data writing when applying an entry from the third index table; the method further includes that, after the task scheduler informs each processor core to move the task parameters of the subtask to be executed from the corresponding first cache to the corresponding storage area in the second cache, the task scheduler changes the linked list for data writing into the linked list for data reading, and changes the linked list for data reading into the linked list for data writing; when the task scheduler queries the first index table, the second index table and the third index table, the task scheduler queries the linked list for data reading.

[0256] The GPU task creation system is also used in a graphics processor.

[0257] The graphics processor is also used in an electronic device.

[0258] The structure of the graphics processor and the electronic device can be seen from Figure 2 .

[0259] The flowcharts and block diagrams in the drawings show the possible implementation architecture, function and operation of the system, method and computer program product according to the embodiments of the present disclosure. In this regard, each block in the flowchart or block diagram can represent a module, a program segment or a part of an instruction, which contains one or more executable instructions for implementing the specified logical function. In some alternative implementations, the functions noted in the blocks can also occur in different order from that noted in the drawings. For example, two consecutive blocks can actually be executed substantially in parallel, and sometimes they can be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and the combination of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system that performs the specified function or action, or can be implemented by a combination of special-purpose hardware and computer instructions.

[0260] Having described above several embodiments of the disclosure, any modifications and variations that fall within the scope of the described embodiments are also intended to be within the scope of the disclosure. As will be apparent to those skilled in the art, some modifications and variations to the embodiments described above can be practiced while staying within the scope and spirit of the described embodiments. The foregoing description of the described embodiments has been presented for the purposes of illustration and description. It is not intended to be exhaustive or to limit the described embodiments to the precise form disclosed. Many modifications and variations are possible in light of the above teachings. It is intended that the disclosed embodiments be limited only by the claims.

Claims

1. A GPU task creation system, characterized by, The system is arranged in a GPU, and the system comprises a task scheduler, N processor cores, N first caches, and a second cache, the N first caches correspond to the N processor cores one by one, the second cache is shared by the N processor cores, N is a positive integer; The task scheduler is configured to schedule a task to be executed to at least one processor core for execution; Any one of the processor cores is configured to execute the received task, including starting at least one thread; obtaining task parameters of the received task; Using the task parameters to execute the thread; when a subtask is created in the process of executing the thread, storing the task parameters of the subtask to the first cache corresponding to the processor core; Applying a storage area in the second cache for storing the task parameters of the subtask; The task scheduler is configured to notify the first cache corresponding to each processor core to move the task parameters of the subtask to the corresponding storage area in the second cache when all the threads started by each processor core are executed, and when the processor core receives the subtask, access the second cache to obtain the task parameters of the subtask.

2. The system of claim 1, wherein, The task to be executed comprises a parent task created by a CPU and a subtask to be executed created by the system, and the task scheduler is further configured to, Count a first thread number, the first thread number being a total number of threads of the subtask to be executed created by the system; When the first thread number reaches a first value, notify the processor core executing the parent task to stop executing the parent task and start scheduling the subtask to be executed created by the system to at least one processor core for execution, the first value being a product of a maximum number of threads executed in parallel by the GPU and a saturation ratio; When the first thread number is less than the first value, notify the processor core executing the parent task to continue executing the parent task.

3. The system of claim 1, wherein, The task scheduler further counts execution information of the subtask to be executed, the execution information indicating a number of times of executing the subtask and a storage area of the task parameters used each time the subtask is executed in the second cache; Any one of the processor cores is further configured to transmit creation information of the subtask to the task scheduler, the creation information comprising a pointer of a data structure of the subtask, a number of the storage area of the task parameters of the subtask in the second cache, and a number of times of executing the subtask; The task scheduler is further configured to update the execution information of the subtask according to the creation information of the subtask; when any one of the subtasks is scheduled to any one of the processor cores, output a storage position of the task parameters of the subtask to the processor core according to the execution information of the subtask.

4. The system of claim 3, wherein, The second cache comprises a parameter storage space for data writing and a parameter storage space for data reading, Any one of the processor cores is specifically configured to apply a storage area in the parameter storage space for data writing; The task scheduler is further configured to change the parameter storage space for data writing to the parameter storage space for data reading and change the parameter storage space for data reading to the parameter storage space for data writing after the first cache moves the task parameters of the subtask to be executed to the corresponding storage area in the second cache; When the task scheduler schedules any one subtask to any one processor core, the storage location of the task parameters output to the processor core belongs to the parameter storage space for data reading; The processor core is specifically configured to access the parameter storage space for data reading according to the received storage location to obtain the task parameters of the subtask.

5. The system of claim 3, wherein, The task scheduler comprises a first index table and a second index table, the second cache comprises a third index table, the execution information of the subtask comprises a group of first execution information and a plurality of groups of second execution information, each group of second execution information corresponds to one execution of the subtask, When the i th entry of the first index table corresponds to the i th subtask to be executed, the i th entry is used to store the first execution information corresponding to the i th subtask, the first execution information corresponding to the i th subtask comprises a pointer of a data structure of the i th subtask, and the number of the storage area of the second execution information corresponding to the first execution of the i th subtask in the third index table, i is a positive integer; When the j th entry of the second index table corresponds to the k th execution of the i th subtask to be executed, the j th entry is used to store the second execution information corresponding to the k th execution of the i th subtask and the number of the storage area of the second execution information corresponding to the k th execution of the i th subtask in the third index table, the second execution information corresponding to the k th execution of the i th subtask comprises the number of the storage area of the task parameters used by the i th subtask in the k th execution in the second cache, the length of the task parameters used by the i th subtask in the k th execution, the number of the storage area of the second execution information corresponding to the k+1 th execution of the i th subtask in the third index table, and the number of subsequent executions of the i th subtask, j and k are positive integers.

6. The system of claim 5, wherein, The task scheduler is specifically configured to: query whether the execution information of the same subtask has been stored in the task scheduler according to the creation information of the subtask; select an entry from the first index table for storing the first execution information corresponding to the subtask and select an entry from the second index table for storing a group of second execution information corresponding to the subtask when the execution information of the same subtask has not been stored in the task scheduler; apply an entry in the third index table for storing a group of second execution information corresponding to the subtask; write the pointer of the data structure of the subtask into the selected entry in the first index table; write, in the selected entry in the second index table, a number included in the creation information as a number of a storage area in the second cache used by the first execution of the subtask; write, in the selected entry in the second index table, a number included in the creation information as a number of a storage area in the second cache used by the first execution of the subtask; write, in the selected entry in the second index table, a length of the task parameter of the subtask as a length of the task parameter used by the first execution of the subtask; write, in the selected entry in the second index table, an invalid identifier as a number of an entry in the third index table corresponding to the second execution of the subtask; write, in the selected entry in the second index table, 1 as a number of subsequent executions of the subtask.

7. The system of claim 5, wherein, The task scheduler is specifically configured to: query, according to the creation information of the subtask, whether execution information of the same subtask has been stored in the task scheduler; when the execution information of the same subtask has been stored in the task scheduler and the same subtask is the ith subtask, query the second index table and / or the third index table to determine all second execution information corresponding to the first x executions of the ith subtask, and when any one group of second execution information satisfies a first condition, add a length of the task parameter of the subtask to a length of the task parameter included in the second execution information, and add a number of executions of the subtask to a number of subsequent executions of the subtask included in the second execution information; x is a smaller one of a second numerical value and a total number of executions of the ith subtask, and x is a positive integer; the first condition is that a sum of a number of a storage area in the second cache used by the task parameter corresponding to the second execution information and the length of the task parameter is equal to the number included in the creation information.

8. The system of claim 7, wherein, the first execution of the ith subtask corresponds to a pth entry in the second index table, p is a positive integer, and the task scheduler is specifically configured to: when there is no entry satisfying the first condition, select an entry from the second index table for storing a group of second execution information corresponding to the ith subtask; apply an entry in the third index table for storing a group of second execution information corresponding to the ith subtask; write, in the selected entry in the second index table, a number of the entry applied in the third index table as a number of a storage area in the third index table corresponding to the second execution information of the first execution of the ith subtask; write, in the selected entry in the second index table, a number included in the creation information as a number of a storage area in the second cache used by the first execution of the ith subtask; write, in the selected entry in the second index table, a length of the task parameter of the subtask as a length of the task parameter used by the first execution of the ith subtask; writing, as the number of the entry in the third index table corresponding to the second execution of the ith subtask, the number stored in the entry in the first index table corresponding to the ith subtask in the selected entry in the second index table; accumulating the number of executions of the subtask and the subsequent execution number stored in the pth entry as the subsequent execution number of the ith subtask, and writing the subsequent execution number in the selected entry in the second index table; updating the number stored in the entry in the first index table corresponding to the ith subtask to the number of the entry applied in the third index table.

9. The system of claim 6 or 7, wherein, The task scheduler is specifically configured to: query whether the first index table has stored the pointer included in the creation information; when the first index table has stored the pointer included in the creation information, determine that the execution information of the same subtask has been stored in the task scheduler; when the first index table has not stored the pointer included in the creation information, determine that the execution information of the same subtask has not been stored in the task scheduler.

10. The system of any one of claims 6-8, wherein, The first index table, the second index table, and the third index table each include a linked list for data writing and a linked list for data reading, The task scheduler is specifically configured to, when selecting entries from the first index table and the second index table, select entries from the linked list for data writing; and when applying entries from the third index table, apply entries from the linked list for data writing. The task scheduler is further configured to, after notifying each processor core to move the task parameters of the subtask to be executed from the corresponding first cache to the corresponding storage area in the second cache, change the linked list for data writing to the linked list for data reading, and change the linked list for data reading to the linked list for data writing; and the task scheduler is specifically configured to, when querying the first index table, the second index table, and the third index table, query the linked list for data reading.

11. A graphics processor, comprising: The GPU task creation system of any one of claims 1-10.

12. An electronic device, comprising: The graphics processor of claim 11.

13. A GPU task creation method, comprising: The method is performed by a GPU task creation system, the system is arranged in a GPU, the system includes a task scheduler, N processor cores, N first caches, and a second cache, the N first caches correspond to the N processor cores one by one, the second cache is shared by the N processor cores, and N is a positive integer; the method includes: scheduling, by using the task scheduler, a task to be executed to at least one processor core for execution; using any one processor core to execute the received task, including: starting at least one thread; obtaining task parameters of the received task; executing the thread by using the task parameters; when a subtask is created in the process of executing the thread, storing task parameters of the subtask to a first cache corresponding to the processor core; and applying a storage area in the second cache for storing the task parameters of the subtask. The task scheduler is used to notify the corresponding first cache of the processor core to move the task parameters of the subtask to the corresponding storage area in the second cache when all the threads started by the processor core are executed, and the processor core accesses the second cache to obtain the task parameters of the subtask when the processor core receives the subtask.

Citation Information

Patent Citations

  • Locality quantification-based parallel task allocation scheduling method for multi-core system

    CN110647390A

  • Task scheduling method and system and hardware task scheduler

    CN115469976A