Task processing method, device, electronic device and storage medium
By detecting the operating status of heterogeneous processing units and asynchronously allocating tasks, the problem of resource waste in heterogeneous computing platforms is solved, and computing efficiency and throughput are improved.
Patent Information
- Application Number
- CN202111059444.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-10
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2041-09-10
AI Technical Summary
In heterogeneous computing platforms, resource waste of heterogeneous processing units leads to low computing efficiency.
By detecting the running status of the heterogeneous processing units, when there are no pending subtasks, subtasks are taken from multiple target threads and put into the task queue, and processed by the idle heterogeneous processing units to achieve asynchronous task allocation.
The resource utilization efficiency and system throughput of the heterogeneous processing units are improved, resource waste is avoided, and continuous processing of the heterogeneous processing units is achieved.
Smart Images

Figure CN113886035B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of data processing technology, and in particular to a task processing method, device, electronic device, and storage medium. Background Art
[0002] In many data processing scenarios, data volumes are rapidly increasing, and computing tasks are becoming increasingly complex. Traditional general-purpose CPUs are no longer able to meet the performance demands of increasingly complex computing tasks. In this context, heterogeneous computing platforms, comprised of multiple computing platforms, have rapidly developed. Common heterogeneous computing platforms include FPGAs, GPUs, and ASICs.
[0003] When performing task processing based on a heterogeneous mode, the number of CPU threads is generally greater than the number of heterogeneous processing units. In related technologies, a round-robin approach is used to allocate a fixed heterogeneous processing unit to each CPU thread. This may result in a situation where a heterogeneous processing unit that has completed task processing is not allocated a new thread and is in a waiting state, thereby wasting resources of the heterogeneous processing units. Summary of the Invention
[0004] The present disclosure provides a task processing method, device, electronic device, and storage medium to at least address the resource waste problem of heterogeneous processing units in related technologies. The technical solutions of the present disclosure are as follows:
[0005] According to a first aspect of an embodiment of the present disclosure, there is provided a task processing method, comprising:
[0006] When there is no subtask to be processed in the task queue, one subtask is taken from each of the multiple target threads in the current batch and put into the task queue; the multiple target threads are subsets of the threads to be processed;
[0007] detecting the operating status of a plurality of heterogeneous processing units; wherein the number of the target threads is greater than the number of the heterogeneous processing units, and the heterogeneous processing units are hardware units adapted to the subtasks;
[0008] When there is a target heterogeneous processing unit among the multiple heterogeneous processing units, the multiple subtasks in the task queue are processed based on the target heterogeneous processing unit; the running state of the target heterogeneous processing unit is an idle state.
[0009] In an exemplary embodiment, the method further comprises:
[0010] Based on the attribute information of the subtasks in the thread to be extracted, multiple target threads of the current batch are extracted from the thread to be extracted.
[0011] In an exemplary embodiment, the attribute information of the subtask is used to represent the time when the subtask enters the thread;
[0012] The method further comprises:
[0013] sorting the multiple threads based on time information of a first subtask in the multiple threads entering a thread to obtain a thread sorting table;
[0014] In the thread sorting table, the time when the first subtask in the thread ranked earlier enters the thread is earlier than the time when the first subtask in the thread ranked later enters the thread.
[0015] In an exemplary embodiment, extracting the multiple target threads of the current batch from the threads to be extracted includes:
[0016] Extracting, from the threads to be extracted, a plurality of threads that are ranked first in the thread sorting table;
[0017] The extracted multiple threads are determined as multiple target threads of the current batch.
[0018] In an exemplary embodiment, taking out a subtask from each of the multiple target threads in the current batch and putting it into the task queue includes:
[0019] Based on the time when the multiple subtasks are taken out and enter the thread, the multiple subtasks are sequentially placed into the task queue;
[0020] Among them, the time when the subtask that enters the thread first enters the task queue is earlier than the time when the subtask enters the thread later; the time when the subtask that enters the thread first enters the target heterogeneous processing unit is earlier than the time when the subtask enters the thread later.
[0021] In an exemplary embodiment, the subtask includes a task identifier, and the task identifier is used to identify the target task to which the subtask belongs, and the target task is split into multiple subtasks with the same task identifier;
[0022] The process of extracting a subtask from each of the multiple target threads in the current batch further includes:
[0023] Putting the multiple subtasks taken from the multiple target threads into a task queue;
[0024] Based on the task identifier of the subtask, determining the number of times the subtask with the task identifier enters the task queue;
[0025] When the subtask with the task identifier enters the task queue twice or more, obtaining cache data corresponding to the task identifier;
[0026] The to-be-processed data included in the subtask and the cached data corresponding to the task identifier are determined as data required to process the subtask.
[0027] In an exemplary embodiment, the subtask further includes a thread identifier;
[0028] The processing of the plurality of subtasks taken from the plurality of target threads based on the target heterogeneous processing unit includes:
[0029] Processing the data required for processing the subtask by the target heterogeneous processing unit to obtain processed data corresponding to the subtask;
[0030] Based on the thread identifier included in the subtask, the processed data is updated to a cache area corresponding to the thread identifier.
[0031] In an exemplary embodiment, multiple subtasks corresponding to the same target task are split into the same thread;
[0032] The method further comprises:
[0033] When the number of times the subtask with the task identifier enters the task queue is one, determining the original thread where the subtask is located based on the thread identifier included in the subtask;
[0034] Determining a previously processed subtask of the subtask in the original thread;
[0035] Obtaining cache data corresponding to the task identifier of the processed subtask;
[0036] The cache data corresponding to the task identifier of the processed subtask is determined as the processing result of the target task; the processed subtask is the last processed subtask among the multiple subtasks included in the target task.
[0037] According to a second aspect of an embodiment of the present disclosure, there is provided a task processing device, including:
[0038] The subtask fetching unit is configured to fetch a subtask from each of a plurality of target threads in a current batch and put it into the task queue when there is no subtask to be processed in the task queue; the plurality of target threads are subsets of the threads to be processed;
[0039] An operating status detection unit is configured to detect the operating status of a plurality of heterogeneous processing units; the number of the target threads is greater than the number of the heterogeneous processing units, and the heterogeneous processing units are hardware units adapted to the subtask;
[0040] The subtask processing unit is configured to process multiple subtasks in the task queue based on a target heterogeneous processing unit when there is a target heterogeneous processing unit among the multiple heterogeneous processing units; the operating state of the target heterogeneous processing unit is an idle state.
[0041] In an exemplary embodiment, the apparatus further comprises:
[0042] The first extraction unit is configured to extract the multiple target threads of the current batch from the threads to be extracted based on the attribute information of the subtasks in the threads to be extracted.
[0043] In an exemplary embodiment, the attribute information of the subtask is used to represent the time when the subtask enters the thread;
[0044] The device further comprises:
[0045] a thread sorting unit configured to sort the multiple threads based on time information of a first subtask in the multiple threads entering the thread, to obtain a thread sorting table;
[0046] In the thread sorting table, the time when the first subtask in the thread ranked earlier enters the thread is earlier than the time when the first subtask in the thread ranked later enters the thread.
[0047] In an exemplary embodiment, the first extraction unit includes:
[0048] A second extraction unit is configured to extract a plurality of threads that are ranked first in the thread sorting table from the threads to be extracted;
[0049] The first determining unit is configured to determine the extracted multiple threads as the multiple target threads of the current batch.
[0050] In an exemplary embodiment, the subtask fetching unit includes:
[0051] a subtask placing unit configured to sequentially place the plurality of subtasks into the task queue based on the time at which the plurality of subtasks taken out enter the thread;
[0052] Among them, the time when the subtask that enters the thread first enters the task queue is earlier than the time when the subtask enters the thread later; the time when the subtask that enters the thread first enters the target heterogeneous processing unit is earlier than the time when the subtask enters the thread later.
[0053] In an exemplary embodiment, the subtask includes a task identifier, and the task identifier is used to identify the target task to which the subtask belongs, and the target task is split into multiple subtasks with the same task identifier;
[0054] The device further comprises:
[0055] a subtask placing unit configured to place a plurality of subtasks taken from the plurality of target threads into a task queue;
[0056] a second determining unit configured to determine, based on the task identifier of the subtask, the number of times the subtask with the task identifier enters the task queue;
[0057] A first acquiring unit is configured to acquire cache data corresponding to the task identifier when the number of times the subtask with the task identifier enters the task queue is greater than or equal to two times;
[0058] The third determining unit is configured to determine the to-be-processed data included in the subtask and the cached data corresponding to the task identifier as data required for processing the subtask.
[0059] In an exemplary embodiment, the subtask further includes a thread identifier;
[0060] The subtask processing unit includes:
[0061] a processed data generating unit configured to process the data required for processing the subtask by the target heterogeneous processing unit to obtain processed data corresponding to the subtask;
[0062] The data updating unit is configured to execute, based on the thread identifier included in the subtask, updating the processed data to a cache area corresponding to the thread identifier.
[0063] In an exemplary embodiment, multiple subtasks corresponding to the same target task are split into the same thread;
[0064] The device further comprises:
[0065] an original thread determining unit configured to determine, when the number of times a subtask with the task identifier enters the task queue is one, an original thread where the subtask is located based on the thread identifier included in the subtask;
[0066] a processed subtask determining unit, configured to determine a previously processed subtask of the subtask in the original thread;
[0067] A second acquiring unit is configured to acquire cache data corresponding to the task identifier of the processed subtask;
[0068] The fourth determining unit is configured to determine the cache data corresponding to the task identifier of the processed subtask as the processing result of the target task; the processed subtask is the last processed subtask among the multiple subtasks included in the target task.
[0069] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement the task processing method as described above.
[0070] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided. When instructions in the computer-readable storage medium are executed by a processor of a server, the server is enabled to perform the task processing method described above.
[0071] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, which includes a computer program stored in a readable storage medium, and at least one processor of a computer device reads and executes the computer program from the readable storage medium, so that the device performs the above-mentioned task processing method.
[0072] The technical solutions provided by the embodiments of the present disclosure bring at least the following beneficial effects:
[0073] The present disclosure takes out a subtask from each of the multiple target threads of the current batch when there is no pending subtask; detects the running status of multiple heterogeneous processing units, and when there is an idle heterogeneous processing unit among the multiple heterogeneous processing units, processes the multiple subtasks taken out from the target thread based on the idle heterogeneous processing unit. The present disclosure takes out the multiple subtasks from the multiple target threads as pending subtasks and enters the idle heterogeneous processing unit for processing, wherein the taking out of the subtasks from the target thread and the processing of the subtasks by the heterogeneous processing unit are implemented asynchronously and do not affect each other, that is, when there is no pending subtask, the operation of taking out the subtask from the multiple target threads is performed; when the heterogeneous processing unit finishes executing the current subtask, it will continue to process the incoming pending subtask, so that the current pending subtask can be assigned according to the running status of the heterogeneous processing unit, so that the heterogeneous processing unit can realize continuous processing of the pending subtask, avoid the waste of resources caused by the idle heterogeneous processing unit, and improve the resource utilization efficiency of the heterogeneous processing unit and the throughput of the system.
[0074] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0075] The accompanying drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute an improper limitation of the present disclosure.
[0076] Figure 1 The figure is a flowchart showing a task processing method according to an exemplary embodiment.
[0077] Figure 2 The figure is a flow chart of a target thread extraction method according to an exemplary embodiment.
[0078] Figure 3 The figure is a flowchart of a method for determining data required for processing a subtask according to an exemplary embodiment.
[0079] Figure 4 The figure is a flow chart of a subtask processing method according to an exemplary embodiment.
[0080] Figure 5 The figure is a flow chart of a method for determining a task processing result according to an exemplary embodiment.
[0081] Figure 6 The figure is a schematic diagram of a task processing flow according to an exemplary embodiment.
[0082] Figure 7 The figure is a block diagram of a task processing device according to an exemplary embodiment.
[0083] Figure 8 The figure is a schematic diagram showing a device structure according to an exemplary embodiment. DETAILED DESCRIPTION
[0084] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
[0085] It should be noted that the terms "first," "second," and the like in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or precedence. It should be understood that the numbers used in this manner are interchangeable where appropriate so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure as detailed in the appended claims.
[0086] In order to solve the problem of resource waste of heterogeneous processing units in the related art when using heterogeneous processing units to perform task processing, the present disclosure provides a task processing method. Figure 1 The execution subject of the method may be a terminal device, and the method may specifically include:
[0087] S110. When there is no subtask to be processed in the task queue, take out a subtask from each of the multiple target threads in the current batch and put it into the task queue; the multiple target threads are a subset of the threads to be processed.
[0088] In the disclosed embodiments, pending subtasks may refer to subtasks that have been extracted from multiple target threads but have not yet been processed by the heterogeneous processing unit. Thus, if no pending subtasks exist, one subtask may be extracted from each of the multiple target threads in the current batch as the pending subtask. The pending threads may be all threads in the system, each containing at least one subtask.
[0089] In an optional embodiment, the subtask taken out from the target thread can be placed in the task queue, and the judgment of whether there is a subtask to be processed can also be converted into a judgment of whether the task queue is empty. For example, if the task queue is empty, it means that there is no subtask to be processed, and the subtask needs to be taken out; if the task queue is not empty, it means that there is a subtask to be processed.
[0090] In an optional embodiment, multiple subtasks extracted from multiple target threads in the current batch are sequentially placed into the task queue based on the time at which they entered the thread. A subtask that entered the thread earlier enters the task queue earlier than a subtask that entered the thread later, and a subtask that entered the thread earlier enters the target heterogeneous processing unit earlier than a subtask that entered the thread later. This ensures that subtasks that entered the thread earlier enter the task queue first and, accordingly, are processed in the target heterogeneous processing unit first, i.e., on a "first-come, first-served" basis. This improves subtask processing efficiency and shortens waiting time for subtasks.
[0091] In an optional embodiment, since the number of subtasks contained in each target thread of the current batch may be different, when taking out subtasks from multiple target threads, some target threads may no longer have subtasks to be taken out. At this time, the subtask taking out operation can be directly performed on the target thread that has subtasks to be taken out, and the target thread that no longer has subtasks to be taken out is not accessed, thereby saving the time of the subtask taking out operation and improving the efficiency of determining the tasks to be processed.
[0092] In an optional embodiment, existing threads can be processed in batches, with multiple threads extracted from the current remaining threads for processing each time. Each subtask has corresponding attribute information, so that based on the attribute information of the subtasks in the thread to be extracted, multiple target threads for the current batch can be extracted from the threads to be extracted. The number of target threads in each batch can be the same or different. Since threads are concurrent, by processing threads in batches, the number of threads in each batch can be reduced, thereby reducing the number of concurrent threads and improving the processing efficiency of subtasks.
[0093] In one specific embodiment, the attribute information of a subtask can be the time when the subtask entered the corresponding thread. Accordingly, the multiple threads can be sorted based on the time when the first subtask in the multiple threads entered the thread, thereby generating a thread sorting table. In the thread sorting table, the time when the first subtask in the first-order thread entered the thread is earlier than the time when the first subtask in the second-order thread entered the thread. Based on the first-come, first-served principle, the subtask that entered the thread first is processed first, thereby avoiding long waiting times for the subtask and improving task processing efficiency.
[0094] In one specific embodiment, the attribute information of a subtask can be a processing priority that characterizes the subtask; accordingly, the multiple threads can be sorted based on the processing priority of the first subtask in the multiple threads to obtain a thread sorting table; wherein, in the thread sorting table, the priority of the first subtask in the first thread is higher than the priority of the first subtask in the second thread. Determining the processing order of subtasks based on their priorities enables personalized processing of subtasks to meet different usage scenarios.
[0095] See also Figure 2 , which shows a target thread extraction method, which may include:
[0096] S210. Extract, from the threads to be extracted, a plurality of threads that are ranked first in the thread sorting table.
[0097] S220. Determine the extracted multiple threads as multiple target threads of the current batch.
[0098] When thread extraction begins, all currently selected threads are selected. Based on the thread sorting table, the top threads are selected as the target threads for the current batch. When thread extraction is repeated, the remaining threads are selected, and based on their order in the thread sorting table, the top threads are selected as the target threads for the current batch. Extracting threads based on the order of each thread in the thread sorting table prioritizes the extraction of top threads, allowing their subtasks to be processed with priority, consistent with their attribute information.
[0099] Since the threads are constantly running, subtasks will continuously enter the corresponding threads; therefore, in the specific implementation process, the threads can be processed in segments. For example, the subtasks entering the threads within a processing cycle can be obtained at preset time intervals for processing, that is, the subtasks in all threads are obtained every time t, and then the subtasks in the obtained threads are processed. Since the number of subtasks in all threads obtained each time may be different, the length of each processing cycle may be different; in each processing cycle, the above-mentioned thread extraction, subtask removal and other related operations are performed again.
[0100] S120. Detecting the operating status of multiple heterogeneous processing units; the number of the target threads is greater than the number of the heterogeneous processing units, and the heterogeneous processing units are hardware units adapted to the subtasks.
[0101] Heterogeneous computing in this embodiment refers to a computing method that uses computing units with different types of instruction sets and architectures to form a system. Common computing unit types include CPU, GPU, DSP, ASIC, FPGA, etc.
[0102] The heterogeneous processing unit in the embodiment of the present disclosure may be a coprocessor, specifically a hardware coprocessor. A hardware coprocessor is a hardware circuit module inside the CPU for processing specific algorithms or logical operations, which can be understood as a special accelerator. A hardware coprocessor can be used to reduce the burden of specific processing tasks on the system microprocessor. For example, a math coprocessor can control digital processing; a graphics coprocessor can handle video rendering. A coprocessor extends the core processing function by extending the instruction set or providing configuration registers. One or more coprocessors can be connected to the CPU core through a coprocessor interface. The coprocessor can be accessed through a set of CPU instructions with a dedicated, provided interface.
[0103] In one specific embodiment, a coprocessor can be embedded or plugged into a terminal device to assist the terminal device's CPU in performing task processing. The coprocessor can specifically include multiple heterogeneous processing units, each of which can be a kernel instance. A kernel instance is an FPGA instance. Each FPGA can construct multiple hardware instances based on the availability of hardware resources, and each instance is an independent computing unit. The FPGA (Field Programmable Gate Array) is a further development of programmable devices such as PALs and GALs. It emerged as a semi-custom circuit in the field of application-specific integrated circuits (ASICs), addressing both the shortcomings of custom circuits and the limited number of gates in existing programmable devices.
[0104] S130. When there is a target heterogeneous processing unit among the multiple heterogeneous processing units, the multiple subtasks in the task queue are processed based on the target heterogeneous processing unit; the operating state of the target heterogeneous processing unit is an idle state.
[0105] Each subtask includes a task identifier, which is used to identify the target task to which the subtask belongs. The target task is split into multiple subtasks with the same task identifier; see Figure 3 , which shows a method for determining data required for processing a subtask, which may include:
[0106] S310 . Put the multiple subtasks taken from the multiple target threads into a task queue.
[0107] S320. Based on the task identifier of the subtask, determine the number of times the subtask with the task identifier enters the task queue.
[0108] S330. When the number of times the subtask with the task identifier enters the task queue is greater than or equal to two times, obtain cache data corresponding to the task identifier.
[0109] S340. Determine the to-be-processed data included in the subtask and the cached data corresponding to the task identifier as data required to process the subtask.
[0110] In a specific embodiment, there may be a dependency relationship between the multiple subtasks obtained by splitting the same target task, and the processing of the latter subtask needs to depend on the processing result of the previous subtask. Therefore, we can first determine the number of times the subtask with the corresponding task identifier enters the task queue to determine whether the processing of the current subtask needs to depend on the processing result of the previous subtask. Whenever a subtask enters the task queue, it will be counted based on the task ID of each subtask. When the number of times a subtask with the task ID enters the task queue is once, it means that the subtask with the task ID enters the task queue for the first time. Processing the subtask does not need to rely on pre-processing data, and the data contained in the current subtask can be directly used as the data required to process the subtask; when the number of times a subtask with the task ID enters the task queue is greater than or equal to two times, it means that other subtasks with the task ID have been processed before, and the cached data corresponding to the task ID is obtained accordingly. The cached data is the data obtained after processing other subtasks with the task ID, and then the data to be processed and the cached data contained in the current subtask are determined as the data required to process the current subtask. Specifically, the data to be processed and the corresponding cached data contained in the current subtask are packaged into the task queue.
[0111] In a specific embodiment, the target task may be decoding a video of duration N. The video of duration N is divided into multiple video segments, including segment 0, segment 1, segment 2, etc., and decoding each video segment can be considered a subtask, resulting in subtask 0, subtask 1, subtask 2, etc. When processing this target task, subtask 0, which decodes segment 0, is first processed and obtains corresponding decoding information 0. The decoding of segment 1 depends on the decoding information 0 of segment 0, and thus the processing of subtask 1 depends on the decoding information of subtask 0. Similarly, the decoding task of a video of duration N can be implemented.
[0112] Based on the task identifier of the subtask, it is determined whether it belongs to the same target task. When processing subsequent subtasks belonging to the same target task, the cached data of the previously processed subtask is obtained based on the same task identifier, thereby improving the efficiency and accuracy of determining the data required for processing the subtask.
[0113] In a specific embodiment, a corresponding cache area can be set for each thread, and each cache area can be identified by a thread identifier; in addition, in addition to setting a cache area corresponding to each thread, a backup cache area can also be set. When the cache area corresponding to each thread is full but data needs to be stored, the data can be stored in the backup cache area. Here, a cache area with a preset storage space can be allocated to each thread. However, since some threads have more subtasks and the corresponding generated processing data is more, the cache area may be full and there is nowhere to store the data. The data that has nowhere to be stored can be stored in the backup cache area. By setting an independent cache area for each thread, it is convenient to access cache data based on the thread identifier, thereby improving data access efficiency. In addition, setting a cache area with a preset space for each thread and setting a backup cache area can save storage space and solve the problem that the existing cache area is full and cannot store data.
[0114] In a specific embodiment, the subtask also includes a thread identifier, that is, the thread identifier of the thread where the subtask is located; Figure 4 , which shows a subtask processing method, which may include:
[0115] S410. Process the data required for processing the subtask through the target heterogeneous processing unit to obtain processed data corresponding to the subtask.
[0116] S420. Based on the thread identifier included in the subtask, update the processed data to a cache area corresponding to the thread identifier.
[0117] The idle state in the embodiment of the present disclosure may refer to a state in which the processing of the previous batch of subtasks has been completed and the next batch of subtasks is ready to be processed; each subtask in the task queue will enter the heterogeneous processing unit in the idle state at one time, and each subtask enters the heterogeneous processing unit, and the corresponding heterogeneous processing unit obtains the data required to process the subtask; wherein the extraction of subtasks from the target thread and the processing of subtasks by the heterogeneous processing unit are implemented asynchronously and do not affect each other. When the processing of the subtask is completed, the obtained data is updated to the corresponding cache area. In the cache area, it can be stored in the form of key values. For example, the key can be the task identifier, and the value can be the data corresponding to the task identifier. Data storage in the form of key values can facilitate data management and data access. By setting an independent cache area for each thread and storing the processed data corresponding to the corresponding thread in the cache area corresponding to the thread identifier, it is convenient to access and obtain cached data based on the thread identifier in the future, thereby improving data access efficiency.
[0118] In the embodiment of the present disclosure, multiple subtasks of the same target task can be split into the same thread; please refer to Figure 5 , which shows a method for determining a task processing result, which may include:
[0119] S510 . When the number of times the subtask with the task identifier enters the task queue is one, determine the original thread where the subtask is located based on the thread identifier included in the subtask.
[0120] S520: Determine the previous processed subtask of the subtask in the original thread.
[0121] S530. Obtain cache data corresponding to the task identifier of the processed subtask.
[0122] S540. Determine the cached data corresponding to the task identifier of the processed subtask as the processing result of the target task; the processed subtask is the last processed subtask among the multiple subtasks included in the target task.
[0123] When subtask a enters the task queue once, it indicates that the previous subtask b, which is in the same thread as subtask a and adjacent to subtask a, is the last subtask processed among the multiple subtasks of the target task A corresponding to subtask b. This indicates that the processing of target task A has been completed. At this time, based on the task ID of subtask b, the cache data corresponding to the task ID of subtask b can be obtained from the cache area corresponding to the thread where subtask b is located, and this cache data can be determined as the processed data obtained by processing the target task. By judging the task ID of the subtask currently entering the task queue, the completed target task can be determined in a timely manner and the corresponding task processing data can be extracted, thereby improving the feedback efficiency of task processing results.
[0124] The present disclosure takes out a subtask from each of the multiple target threads of the current batch when there is no pending subtask; detects the running status of multiple heterogeneous processing units, and when there is an idle heterogeneous processing unit among the multiple heterogeneous processing units, processes the multiple subtasks taken out from the target thread based on the idle heterogeneous processing unit. The present disclosure takes out the multiple subtasks from the multiple target threads as pending subtasks and enters the idle heterogeneous processing unit for processing, wherein the taking out of the subtasks from the target thread and the processing of the subtasks by the heterogeneous processing unit are implemented asynchronously and do not affect each other, that is, when there is no pending subtask, the operation of taking out the subtask from the multiple target threads is performed; when the heterogeneous processing unit finishes executing the current subtask, it will continue to process the incoming pending subtask, so that the current pending subtask can be assigned according to the running status of the heterogeneous processing unit, so that the heterogeneous processing unit can realize continuous processing of the pending subtask, avoid the waste of resources caused by the idle heterogeneous processing unit, and improve the resource utilization efficiency of the heterogeneous processing unit and the throughput of the system.
[0125] The following is a specific example to illustrate the specific implementation process of this disclosure. Figure 6 , which shows a task processing flow diagram. Multiple subtasks belonging to the same target task can come from the same user or the same application APP; the process may include:
[0126] 1. The pre-processing module aggregates multi-threaded data and extracts multiple threads from all threads on a first-come, first-served basis. Here, we assume that there are 6 threads, 2 heterogeneous processing units, and multiple subtasks of the same target task from the same user. The target task for user User0 can be split into multiple subtasks, such as User0 Part0, User0 Part1, User0 Part2, and so on. The same applies to other users.
[0127] 2. Take out a User Part from each thread and determine the input data and cached data required to process each User Part; obtain the cached data required to process the current subtask from the cache area (backup buffers). Specifically, a mapping method is used to map the calculated data to a limited cache area (backup buffers) based on the user ID.
[0128] 3. The input data and cached data required to process each User Part are packaged together and sent to the first-in-first-out queue (FIFO Queue).
[0129] 4. The heterogeneous processing unit (hardware instance 1 & 2) obtains the subtask to be processed and the data required to process the subtask from the first-in first-out queue (FIFO queue) and obtains the task processing result.
[0130] 5. Update the cache area (backup buffers) based on the task processing results, and data consistency is guaranteed by shared backup buffers.
[0131] Since these modules are asynchronous, once hardware instance 1 or 2 completes its calculation, it can immediately retrieve new pending subtasks from the FIFO queue without waiting, thereby greatly reducing the system's multi-kernel instance scheduling time interval.
[0132] This disclosure can reduce total computation time in scenarios where CPUs and other heterogeneous computing platforms are co-computing, improve the utilization efficiency of hardware computing resources, and increase overall system throughput. This can significantly increase hardware utilization and improve end-to-end system throughput, especially when the number of threads exceeds the number of hardware computing units.
[0133] Figure 7 FIG. 1 is a block diagram of a task processing device according to an exemplary embodiment. Figure 7 , the device comprises:
[0134] The subtask fetching unit 710 is configured to fetch a subtask from each of a plurality of target threads in the current batch and put it into the task queue when there is no subtask to be processed in the task queue; the plurality of target threads are subsets of the threads to be processed;
[0135] The running state detection unit 720 is configured to detect the running state of multiple heterogeneous processing units; the number of the target threads is greater than the number of the heterogeneous processing units, and the heterogeneous processing units are hardware units adapted to the subtasks;
[0136] The subtask processing unit 730 is configured to process multiple subtasks in the task queue based on a target heterogeneous processing unit when there is a target heterogeneous processing unit among the multiple heterogeneous processing units; the operating state of the target heterogeneous processing unit is an idle state.
[0137] In an exemplary embodiment, the apparatus further comprises:
[0138] The first extraction unit is configured to extract the multiple target threads of the current batch from the threads to be extracted based on the attribute information of the subtasks in the threads to be extracted.
[0139] In an exemplary embodiment, the attribute information of the subtask is used to represent the time when the subtask enters the thread;
[0140] The device further comprises:
[0141] a thread sorting unit configured to sort the multiple threads based on time information of a first subtask in the multiple threads entering the thread, to obtain a thread sorting table;
[0142] In the thread sorting table, the time when the first subtask in the thread ranked earlier enters the thread is earlier than the time when the first subtask in the thread ranked later enters the thread.
[0143] In an exemplary embodiment, the first extraction unit includes:
[0144] A second extraction unit is configured to extract a plurality of threads that are ranked first in the thread sorting table from the threads to be extracted;
[0145] The first determining unit is configured to determine the extracted multiple threads as the multiple target threads of the current batch.
[0146] In an exemplary embodiment, the subtask fetching unit includes:
[0147] a subtask placing unit configured to sequentially place the plurality of subtasks into the task queue based on the time at which the plurality of subtasks taken out enter the thread;
[0148] Among them, the time when the subtask that enters the thread first enters the task queue is earlier than the time when the subtask enters the thread later; the time when the subtask that enters the thread first enters the target heterogeneous processing unit is earlier than the time when the subtask enters the thread later.
[0149] In an exemplary embodiment, the subtask includes a task identifier, and the task identifier is used to identify the target task to which the subtask belongs, and the target task is split into multiple subtasks with the same task identifier;
[0150] The device further comprises:
[0151] a subtask placing unit configured to place a plurality of subtasks taken from the plurality of target threads into a task queue;
[0152] a second determining unit configured to determine, based on the task identifier of the subtask, the number of times the subtask with the task identifier enters the task queue;
[0153] A first acquiring unit is configured to acquire cache data corresponding to the task identifier when the number of times the subtask with the task identifier enters the task queue is greater than or equal to two times;
[0154] The third determining unit is configured to determine the to-be-processed data included in the subtask and the cached data corresponding to the task identifier as data required for processing the subtask.
[0155] In an exemplary embodiment, the subtask further includes a thread identifier;
[0156] The subtask processing unit 730 includes:
[0157] a processed data generating unit configured to process the data required for processing the subtask by the target heterogeneous processing unit to obtain processed data corresponding to the subtask;
[0158] The data updating unit is configured to execute, based on the thread identifier included in the subtask, updating the processed data to a cache area corresponding to the thread identifier.
[0159] In an exemplary embodiment, multiple subtasks corresponding to the same target task are split into the same thread;
[0160] The device further comprises:
[0161] an original thread determining unit configured to determine, when the number of times a subtask with the task identifier enters the task queue is one, an original thread where the subtask is located based on the thread identifier included in the subtask;
[0162] a processed subtask determining unit, configured to determine a previously processed subtask of the subtask in the original thread;
[0163] A second acquiring unit is configured to acquire cache data corresponding to the task identifier of the processed subtask;
[0164] The fourth determining unit is configured to determine the cache data corresponding to the task identifier of the processed subtask as the processing result of the target task; the processed subtask is the last processed subtask among the multiple subtasks included in the target task.
[0165] Regarding the apparatus in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0166] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided. Optionally, the computer-readable storage medium may be a ROM, a random access memory (RAM), a CD-ROM, a tape, a floppy disk, an optical data storage device, etc.; when the instructions in the computer-readable storage medium are executed by the processor of the server, the server is enabled to execute any of the methods described above.
[0167] In an exemplary embodiment, a computer program product is also provided, which includes a computer program stored in a readable storage medium, and at least one processor of a computer device reads and executes the computer program from the readable storage medium, so that the device performs any of the above methods.
[0168] Further, Figure 8 A schematic diagram of the hardware structure of a device for implementing the method provided by an embodiment of the present disclosure is shown, and the device may participate in or include the apparatus provided by an embodiment of the present disclosure. Figure 8 As shown, the device 10 may include one or more (illustrated as 102a, 102b, ..., 102n in the figure) processors 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, a power supply and / or a camera. It will be understood by those skilled in the art that Figure 8 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 8 More or fewer components than shown, or with Figure 8 Different configurations shown.
[0169] It should be noted that the one or more processors 102 and / or other data processing circuits described above may generally be referred to herein as "data processing circuitry." The data processing circuitry may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuitry may be a single, independent processing module, or may be incorporated in whole or in part into any of the other components of the device 10 (or mobile device). As described in the embodiments of the present disclosure, the data processing circuitry serves as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).
[0170] The memory 104 can be used to store software programs and modules of application software, such as program instructions / data storage devices corresponding to the methods described in the embodiments of the present disclosure. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, implementing the above-mentioned player preloading method or player operation method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely located relative to the processor 102, and these remote memories may be connected to the device 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0171] Transmission device 106 is configured to receive or transmit data via a network. A specific example of the aforementioned network may include a wireless network provided by the communications provider of device 10. In one embodiment, transmission device 106 includes a network interface controller (NIC), which can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, transmission device 106 may be a radio frequency (RF) module configured to communicate with the Internet wirelessly.
[0172] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of device 10 (or mobile device).
[0173] Any of the above methods in this embodiment can be based on Figure 8 The device shown is implemented.
[0174] Other embodiments of the present disclosure will readily occur to those skilled in the art after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, with the true scope and spirit of the present disclosure being indicated by the following claims.
[0175] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes can be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A task processing method, characterized in that: include: When there are no pending subtasks in the task queue, one subtask is taken from each of the multiple target threads in the current batch and put into the task queue; The multiple target threads are subsets of the threads to be processed; the subtasks include a task identifier, which is used to identify the target task to which the subtasks belong, and the target task is split into multiple subtasks with the same task identifier; multiple subtasks corresponding to the same target task are split into the same thread; Detecting the operating status of multiple heterogeneous processing units; The number of the target threads is greater than the number of the heterogeneous processing units, and the heterogeneous processing units are hardware units adapted to the subtasks; When a target heterogeneous processing unit exists among the plurality of heterogeneous processing units, processing the plurality of subtasks in the task queue based on the target heterogeneous processing unit; The operating state of the target heterogeneous processing unit is an idle state; Based on the task identifier of the subtask, determining the number of times the subtask with the task identifier enters the task queue; When the subtask with the task identifier enters the task queue twice or more, obtaining cache data corresponding to the task identifier; Determining the to-be-processed data contained in the subtask and the cached data corresponding to the task identifier as data required to process the subtask; When the number of times the subtask with the task identifier enters the task queue is one, determining the original thread where the subtask is located based on the thread identifier included in the subtask; Determining a previously processed subtask of the subtask in the original thread; Obtaining cache data corresponding to the task identifier of the processed subtask; Determining the cached data corresponding to the task identifier of the processed subtask as the processing result of the target task; The processed subtask is the subtask that is processed last among the multiple subtasks included in the target task.
2. A task processing method according to claim 1, characterized in that: The method further comprises: Based on the attribute information of the subtasks in the thread to be extracted, multiple target threads of the current batch are extracted from the thread to be extracted.
3. A task processing method according to claim 2, characterized in that: The attribute information of the subtask is used to represent the time when the subtask enters the thread; The method further comprises: sorting the multiple threads based on time information of a first subtask in the multiple threads entering a thread to obtain a thread sorting table; In the thread sorting table, the time when the first subtask in the thread ranked earlier enters the thread is earlier than the time when the first subtask in the thread ranked later enters the thread.
4. A task processing method according to claim 3, characterized in that: The step of extracting the plurality of target threads of the current batch from the threads to be extracted includes: Extracting, from the threads to be extracted, a plurality of threads that are ranked first in the thread sorting table; The extracted multiple threads are determined as multiple target threads of the current batch.
5. A task processing method according to claim 1, characterized in that: The step of taking out a subtask from each of the multiple target threads in the current batch and putting it into the task queue includes: Based on the time when the multiple subtasks are taken out and enter the thread, the multiple subtasks are sequentially placed into the task queue; Among them, the time when the subtask that enters the thread first enters the task queue is earlier than the time when the subtask enters the thread later; the time when the subtask that enters the thread first enters the target heterogeneous processing unit is earlier than the time when the subtask enters the thread later.
6. A task processing method according to claim 1, characterized in that: The subtask also includes a thread identifier; The processing of the plurality of subtasks taken from the plurality of target threads based on the target heterogeneous processing unit includes: Processing the data required for processing the subtask by the target heterogeneous processing unit to obtain processed data corresponding to the subtask; Based on the thread identifier included in the subtask, the processed data is updated to a cache area corresponding to the thread identifier.
7. A task processing device, characterized in that: include: The subtask fetching unit is configured to fetch a subtask from each of the multiple target threads of the current batch and put it into the task queue when there is no subtask to be processed in the task queue; The multiple target threads are subsets of the threads to be processed; the subtasks include a task identifier, which is used to identify the target task to which the subtasks belong, and the target task is split into multiple subtasks with the same task identifier; multiple subtasks corresponding to the same target task are split into the same thread; An operating status detection unit, configured to detect the operating status of a plurality of heterogeneous processing units; The number of the target threads is greater than the number of the heterogeneous processing units, and the heterogeneous processing units are hardware units adapted to the subtasks; a subtask processing unit configured to process a plurality of subtasks in the task queue based on a target heterogeneous processing unit when a target heterogeneous processing unit exists among the plurality of heterogeneous processing units; The operating state of the target heterogeneous processing unit is an idle state; a second determining unit configured to determine, based on the task identifier of the subtask, the number of times the subtask with the task identifier enters the task queue; A first acquiring unit is configured to acquire cache data corresponding to the task identifier when the number of times the subtask with the task identifier enters the task queue is greater than or equal to two times; a third determining unit configured to determine the to-be-processed data included in the subtask and the cached data corresponding to the task identifier as data required for processing the subtask; an original thread determining unit configured to determine, when the number of times a subtask with the task identifier enters the task queue is one, an original thread where the subtask is located based on the thread identifier included in the subtask; a processed subtask determining unit, configured to determine a previously processed subtask of the subtask in the original thread; A second acquiring unit is configured to acquire cache data corresponding to the task identifier of the processed subtask; A fourth determining unit is configured to determine the cached data corresponding to the task identifier of the processed subtask as a processing result of the target task; The processed subtask is the subtask that is processed last among the multiple subtasks included in the target task.
8. A task processing device according to claim 7, characterized in that: The device further comprises: The first extraction unit is configured to extract the multiple target threads of the current batch from the threads to be extracted based on the attribute information of the subtasks in the threads to be extracted.
9. The task processing device according to claim 8, characterized in that: The attribute information of the subtask is used to represent the time when the subtask enters the thread; The device further comprises: a thread sorting unit configured to sort the multiple threads based on time information of a first subtask in the multiple threads entering the thread, to obtain a thread sorting table; In the thread sorting table, the time when the first subtask in the thread ranked earlier enters the thread is earlier than the time when the first subtask in the thread ranked later enters the thread.
10. The task processing device according to claim 9, characterized in that: The first extraction unit includes: A second extraction unit is configured to extract a plurality of threads that are ranked first in the thread sorting table from the threads to be extracted; The first determining unit is configured to determine the extracted multiple threads as the multiple target threads of the current batch.
11. The task processing device according to claim 7, characterized in that: The subtask fetching unit includes: a subtask placing unit configured to sequentially place the plurality of subtasks into the task queue based on the time at which the plurality of subtasks taken out enter the thread; Among them, the time when the subtask that enters the thread first enters the task queue is earlier than the time when the subtask enters the thread later; the time when the subtask that enters the thread first enters the target heterogeneous processing unit is earlier than the time when the subtask enters the thread later.
12. A task processing device according to claim 11, characterized in that: The subtask also includes a thread identifier; The subtask processing unit includes: a processed data generating unit configured to process the data required for processing the subtask by the target heterogeneous processing unit to obtain processed data corresponding to the subtask; The data updating unit is configured to execute, based on the thread identifier included in the subtask, updating the processed data to a cache area corresponding to the thread identifier.
13. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the task processing method according to any one of claims 1 to 6.
14. A computer-readable storage medium, characterized in that When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the task processing method according to any one of claims 1 to 6.
15. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the task processing method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Video analysis and accelerating method based on thread level flow line
CN106358003A
Task state management method and device
CN109558237A