Task processing method and device, electronic equipment and readable storage medium
By allocating task processing resources to processing units in a multi-heterogeneous core architecture, the problem of low computing efficiency of electronic devices when performing complex tasks is solved, and more efficient task processing is achieved.
Patent Information
- Application Number
- CN202510124449.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-26
- Publication Date
- 2025-05-27
AI Technical Summary
Electronic devices are less efficient when performing complex tasks using multi-heterogeneous core architectures.
By obtaining the first parameters of the N types of processing units corresponding to the first task, the number of subtasks assigned to the processing unit with parallel processing attributes is indicated, and task processing resources are allocated to the N types of processing units based on this parameter.
The computing efficiency of the electronic device when performing complex tasks is improved, so that N types of processing units can effectively utilize the computing resources required to process the first task.
Smart Images

Figure CN120045325A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of computer technology, and particularly relates to a task processing method, apparatus, electronic device, and readable storage medium. Background Art
[0002] With the continuous development of electronic devices, the computing requirements of electronic devices are also increasing continuously. Therefore, traditional single-core processors can no longer meet the computing requirements of complex tasks on electronic devices.
[0003] Currently, electronic devices can adopt a multi-heterogeneous core architecture to execute complex tasks. A variety of different types of processors are integrated on the multi-heterogeneous core architecture. Different types of processors are processors designed specifically for different specific tasks, and usually have different performance characteristics and power consumption requirements. For example, when a task includes a model training subtask, an image processing subtask, and a digital signal processing subtask, an electronic device can adopt a multi-heterogeneous core architecture to execute this task. The multi-heterogeneous core architecture may include a neural network processor for executing model training tasks, an image processing unit for executing image processing tasks, and a digital signal processor for executing digital signal processing.
[0004] However, when an electronic device adopts a multi-heterogeneous core architecture to execute complex tasks, the computing efficiency of the electronic device is low. Summary of the Invention
[0005] The purpose of the embodiments of this application is to provide a task processing method, apparatus, electronic device, and readable storage medium, which can improve the computing efficiency of electronic devices.
[0006] In a first aspect, the embodiments of this application provide a task processing method, which is applied to an electronic device. The method includes:
[0007] Obtain first parameters of N types of processing units corresponding to a first task; the first parameters are used to indicate the number of subtasks with parallel processing attributes assigned to the processing units; N is an integer greater than 1;
[0008] Based on the first parameters, allocate task processing resources corresponding to the first task to the N types of processing units.
[0009] In a second aspect, the embodiments of this application provide a task processing apparatus, which includes:
[0010] An obtaining module, configured to obtain first parameters of N types of processing units corresponding to a first task; the first parameters are used to indicate the number of subtasks with parallel processing attributes assigned to the processing units; N is an integer greater than 1;
[0011] An allocation module, configured to allocate task processing resources corresponding to the first task to N types of processing units based on the first parameters obtained by the obtaining module.
[0012] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor and a memory. The memory stores a program or instruction that can run on the processor. When the program or instruction is executed by the processor, the steps of the task processing method described in the first aspect are implemented.
[0013] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the task processing method described in the first aspect are implemented.
[0014] In a fifth aspect, an embodiment of the present application provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the task processing method described in the first aspect.
[0015] In a sixth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the task processing method described in the first aspect.
[0016] In the embodiment of the present application, first parameters of N types of processing units corresponding to a first task are obtained; the first parameters are used to indicate the number of subtasks with parallel processing attributes assigned to the processing units; N is an integer greater than 1; and task processing resources corresponding to the first task are allocated to the N types of processing units based on the first parameters. In this way, the electronic device can reasonably allocate the computing resources required for processing the first task to the N types of processing units based on the first parameters of the N types of processing units, so that the N types of processing units can execute the first task using the computing resources required for processing the first task, thereby improving the computing efficiency of the electronic device in executing the first task. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 is a schematic flowchart of a task processing method provided by an embodiment of the present application;
[0018] Figure 2 is a schematic flowchart of a task processing method provided by an embodiment of the present application;
[0019] Figure 3 is a schematic flowchart of a task processing method provided by an embodiment of the present application;
[0020] Figure 4 is a schematic flowchart of a task processing method provided by an embodiment of the present application;
[0021] Figure 5 is a schematic flowchart of a task processing method provided by an embodiment of the present application;
[0022] Figure 6 It is a schematic flowchart of a task processing method provided by an embodiment of the present application;
[0023] Figure 7 It is a schematic flowchart of a task processing method provided by an embodiment of the present application;
[0024] Figure 8 It is a schematic diagram of the calculation distribution of an ALF operator provided by an embodiment of the present application;
[0025] Figure 9 It is a schematic diagram of decoded data on an MVPU provided by an embodiment of the present application;
[0026] Figure 10 It is a curve graph of performance optimization parameters of an ALF operator provided by an embodiment of the present application;
[0027] Figure 11 It is a schematic diagram of the distribution of performance factors of different cores of a CPU provided by an embodiment of the present application;
[0028] Figure 12 It is a curve graph of performance optimization parameters of an ALF operator provided by an embodiment of the present application;
[0029] Figure 13 It is a schematic diagram of the distribution of performance factors of different cores of a CPU provided by an embodiment of the present application;
[0030] Figure 14 It is a curve graph of performance optimization parameters of an ALF operator provided by an embodiment of the present application;
[0031] Figure 15 It is a schematic structural diagram of a task processing method device provided by an embodiment of the present application;
[0032] Figure 16 It is a schematic structural diagram of an electronic device provided by an embodiment of the present application;
[0033] Figure 17 It is a schematic hardware structure diagram of an electronic device provided by an embodiment of the present application. Specific embodiments
[0034] Next, the technical solutions in the embodiments of the present application will be clearly described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art belong to the scope of protection of the present application.
[0035] The terms "first", "second", etc. in the description and claims of this application are used to distinguish similar objects, rather than to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of this application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are usually of the same category, and do not limit the number of objects. For example, the first object can be one or multiple. In addition, "and / or" in the description and claims means at least one of the connected objects, and the character " / ", generally represents an "or" relationship between the associated objects before and after.
[0036] The terms "at least one (item)", "at least one of", etc. in the description and claims of this application refer to any one, any two or more combinations of the objects it contains. For example, at least one (item) of a, b, and c can represent: "a", "b", "c", "a and b", "a and c", "b and c", and "a, b, and c", where a, b, and c can be single or multiple. Similarly, "at least two (items)" means two or more, and its meaning is similar to that of "at least one (item)".
[0037] The task processing method, device, electronic device, and medium provided by the embodiments of this application will be described in detail below with reference to the accompanying drawings, through specific embodiments and their application scenarios.
[0038] The task processing method, task processing device, electronic device, and readable storage medium provided by the embodiments of this application can be applied to complex task scenarios.
[0039] Currently, an electronic device can use a multi-heterogeneous core architecture to execute complex tasks. A variety of different types of processors are integrated on the multi-heterogeneous core architecture. Different types of processors are processors designed for different specific tasks and usually have different performance characteristics and power consumption requirements. For example, when a task includes a model training subtask, an image processing subtask, and a digital signal processing subtask, the electronic device can use a multi-heterogeneous core architecture to execute this task. The multi-heterogeneous core architecture can include a neural network processor for executing model training tasks, an image processing unit for executing image processing tasks, and a digital signal processor for executing digital signal processing.
[0040] However, when an electronic device uses a multi-heterogeneous core architecture to execute complex tasks, how to improve the computing efficiency of the electronic device is an urgent problem to be solved.
[0041] To this end, the embodiments of the present application provide a task processing method, apparatus, electronic device, and medium. By obtaining the first parameters of N types of processing units corresponding to the first task; the first parameters are used to indicate the number of sub-tasks with parallel processing attributes allocated to the processing units; N is an integer greater than 1; and based on the first parameters, task processing resources corresponding to the first task are allocated to the N types of processing units. In this way, the electronic device can reasonably allocate the computing resources required to process the first task to the N types of processing units based on the first parameters of the N types of processing units, so that the N types of processing units can execute the first task using the computing resources required to process the first task, thereby improving the computing efficiency of the electronic device in executing the first task.
[0042] The execution subject of the task processing method provided by the embodiments of the present application can be a task processing apparatus. Exemplarily, the task processing apparatus can be an electronic device, or a functional component or functional entity in the electronic device. Hereinafter, taking the execution subject as an electronic device as an example, the task processing method provided by the embodiments of the present application will be described exemplarily.
[0043] Figure 1 It is a schematic flowchart of the task processing method provided by the embodiments of the present application. As Figure 1 shown, the task processing method provided by the embodiments of the present application may include the following steps 101 and 102.
[0044] Step 101: The electronic device obtains the first parameters of N types of processing units corresponding to the first task.
[0045] In some embodiments of the present application, the above N types of processing units may include at least one of a first processing unit and a second processing unit. The first processing unit is different types of processing units in a multi-heterogeneous core architecture, and the second processing unit is processing units of the same type but with different performance parameters.
[0046] For example, when the electronic device is a mobile phone, the first processing unit may be the Graphic Processing Unit (GPU) and the Neural Processing Unit (NPU) of the mobile phone, and the second processing unit may be different cores on the Central Processing Unit (CPU) of the mobile phone. When the first task is a face recognition task, the mobile phone can control the camera to collect a face image through the CPU, and then transmit the face image to the GPU. The GPU processes the image rendering subtask in the face recognition task, that is, renders the face image. The mobile phone then transmits the face image rendered by the GPU to the NPU through the CPU, and the NPU performs the face image recognition subtask in the face recognition task, that is, recognizes the face from the rendered face image. The NPU passes the recognition result to the CPU, and the CPU performs the unlocking subtask in the face recognition task, that is, unlocks the recognition result. The main process of the face recognition task is controlled by the CPU. The CPU can also perform face recognition, but the GPU is more professional, so the electronic device can execute the face recognition task more efficiently.
[0047] In some embodiments of the present application, the first parameter is used to indicate the number of subtasks with parallel processing attributes assigned to the processing unit, and N is an integer greater than 1.
[0048] In some embodiments of the present application, when the N processing units are N different types of first processing units, the first parameter is the first ratio of the number of subtasks with parallel processing attributes assigned to the first processing unit to the number of subtasks assigned to the first processing unit.
[0049] In some embodiments of the present application, the number of subtasks with parallel processing attributes assigned to the first processing unit can be understood as the number of tasks that have no execution sequence limit among each other, that is, the number of subtasks that can be processed simultaneously.
[0050] For example, when N is 3 and the three types of processing units are CPU, GPU, and NPU, if the CPU is assigned a sub-task, and the image format conversion sub-task is used to indicate converting an image from the RGB format to the YCbCr format, and the pixels of the image are 1080*1080, then the number of image format conversion sub-tasks is 1080*1080, that is, the number of sub-tasks assigned to the CPU is 1080*1080. Since each pixel in the image is converted using the same calculation formula Y=(77*R + 150*G + 29*B), and there is no order of precedence for each row of pixels during format conversion, all pixels can be converted simultaneously. Therefore, the CPU can execute the image format conversion sub-tasks completely in parallel, and the number of sub-tasks with parallel processing attributes assigned to the CPU is 1080*1080. The first ratio of the number of sub-tasks with parallel processing attributes assigned to the CPU to the number of sub-tasks assigned to the first processing unit is 1, that is, the first parameter of the CPU is 1.
[0051] In some embodiments of the present application, among the N types of processing units, the second processing unit includes N sub-processing units with different performance parameters. The first parameter includes the second ratio of the number of sub-tasks with parallel processing attributes assigned to the second processing unit to the number of sub-tasks assigned to the second processing unit, and the N performance parameters of the N sub-processing units.
[0052] For example, when the second processing unit is a CPU and N is 3, the three types of processing units can be cores with different performance factors in the CPU, such as big cores, medium cores, and small cores. Suppose the performance factor of the big core is 1, the performance factor of the medium core is 0.54, and the performance factor of the small core is 0.41. Then the three performance parameters in the first parameter are 1, 0.54, and 0.41. Suppose the CPU is assigned a sub-task, and the image format conversion sub-task is used to indicate converting an image from the RGB format to the YCbCr format, and the pixels of the image are 1080*1080. Then the number of image format conversion sub-tasks is 1080*1080, that is, the number of sub-tasks assigned to the CPU is 1080*1080. Since each pixel in the image is converted using the same calculation formula Y=(77*R + 150*G + 29*B), the CPU can execute the image format conversion sub-tasks completely in parallel. The number of sub-tasks with parallel processing attributes assigned to the CPU is 1080*1080, and the first ratio of the number of sub-tasks with parallel processing attributes assigned to the CPU to the number of sub-tasks assigned to the first processing unit is 1, that is, the second ratio in the first parameter is 1.
[0053] In some embodiments of the present application, among the above N processing units including M different types of first processing units and N-M sub-processing units with different performance parameters in the second processing units, the above first parameter includes the first ratio of the number of subtasks with parallel processing attributes assigned to the above first processing unit to the number of subtasks assigned to the above first processing unit, the second ratio of the number of subtasks with parallel processing attributes assigned to the above second processing unit to the number of subtasks assigned to the above second processing unit, and the performance parameters of each of the above N-M sub-processing units. M is an integer greater than 1 and less than N.
[0054] It should be noted that in the case where the above N processing units include M different types of first processing units and N-M sub-processing units with different performance parameters in the second processing units, the explanation of the above first parameter can refer to the relevant description of the first parameter in the case where the above N processing units are N different types of first processing units, and the relevant description of the first parameter in the N sub-processing units with different performance parameters in the case where the above N processing units include the second processing unit. To avoid repetition, it will not be elaborated here in this embodiment.
[0055] Step 102: The electronic device allocates the task processing resources required for processing the first task to the N processing units based on the first parameter.
[0056] In some embodiments of the present application, in combination with Figure 1 , as Figure 2 shown, the above step 102 can be implemented by the following step 102a and the following step 102b:
[0057] Step 102a: The electronic device determines the occupancy ratios corresponding to the N processing units respectively based on the first parameter.
[0058] In some embodiments of the present application, the above occupancy ratio is the occupancy ratio of the subtasks assigned to the processing unit in the above first task.
[0059] In some embodiments of the present application, the sum value of the above N occupancy ratios is 1.
[0060] In some embodiments of the present application, in combination with Figure 2 , as Figure 3 shown, the above step 102a can be implemented by the following step 102a1 and the following step 102a2:
[0061] Step 102a1: The electronic device determines at least two groups of occupancy ratios and the task optimization parameters corresponding to each group of occupancy ratios based on the first parameter.
[0062] In some embodiments of the present application, each group of the above occupancy ratios can be understood as each group of the above at least two groups of occupancy ratios.
[0063] In some embodiments of the present application, the above-mentioned occupancy ratio includes the candidate occupancy ratios corresponding to the above-mentioned N processing units respectively.
[0064] In some embodiments of the present application, the above-mentioned task optimization parameter can characterize the efficiency improvement amount of the above-mentioned first task, that is, how much the efficiency of the above-mentioned first task is improved. The above-mentioned efficiency improvement amount can be understood as the efficiency improvement amount of the electronic device using the above-mentioned N processing units to process the first task relative to the electronic device using a single-core processor to serially process the above-mentioned first task.
[0065] In some embodiments of the present application, the sum value of each group of occupancy ratios is 1.
[0066] In some embodiments of the present application, when the above-mentioned N processing units include N different types of first processing units, in combination Figure 3 , such as Figure 4 shown, the above-mentioned step 102a1 can be implemented through the following step A1 to the following step A3:
[0067] Step A1: The electronic device calculates the ratio of the number of the i-th type of first processing unit to the first ratio corresponding to the i-th type of first processing unit, and obtains the first value corresponding to the i-th type of first processing unit.
[0068] In some embodiments of the present application, i ∈ [1, N], and i is an integer.
[0069] In some embodiments of the present application, the above-mentioned N different types of first processing units can be different types of processing units in a heterogeneous multi-core architecture. For example, GPU, NPU, and Field Programmable Gate Array (FPGA), etc.
[0070] In some embodiments of the present application, the electronic device can calculate the above-mentioned first value corresponding to the i-th type of first processing unit by using the following formula:
[0071]
[0072] Among them, m i represents the first value corresponding to the i-th type of first processing unit, p i represents the number of the above-mentioned i-th type of first processing unit, and s i represents the ratio of the first ratio corresponding to the above-mentioned i-th type of first processing unit.
[0073] Step A2: The electronic device calculates the difference between the first threshold and the first ratio corresponding to the i-th type of first processing unit, and obtains the second value corresponding to the i-th type of first processing unit.
[0074] In some embodiments of the present application, the above first threshold may be 1.
[0075] In some embodiments of the present application, the electronic device may calculate the second value corresponding to the i-th first processing unit by using the following formula:
[0076] n i =(1 - p i );(2)
[0077] where n i represents the second value corresponding to the i-th first processing unit.
[0078] Step A3: The electronic device determines at least two groups of occupancy ratios and task optimization parameters corresponding to each group of occupancy ratios based on N first values and N second values corresponding to N first processing units.
[0079] In some embodiments of the present application, the electronic device may calculate the sum of the first value corresponding to the i-th first processing unit and the second value corresponding to the i-th processing unit to obtain the fourth value corresponding to the i-th first processing unit, and then determine the at least two groups of occupancy ratios and the task optimization parameters corresponding to each group of occupancy ratios based on the N fourth values corresponding to the N first processing units.
[0080] In some embodiments of the present application, the electronic device may use the following formula to determine at least two groups of occupancy ratios and task optimization parameters corresponding to each group of occupancy ratios:
[0081]
[0082] where m i + n i represents the fourth value corresponding to the i-th processing unit, S represents the task optimization parameter, l i represents the occupancy ratio corresponding to the i-th processing unit, and l 1 + l 2 +... l i +... l N =1.
[0083] In some embodiments of the present application, the electronic device may determine the first correspondence between the task optimization parameter and the occupancy ratio corresponding to each of the N first processing units according to the above formula (3), and then the electronic device may determine at least two groups of occupancy ratios and task optimization parameters corresponding to each group of occupancy ratios based on the above first correspondence.
[0084] In this way, the electronic device calculates the ratio of the number of the i-th type of first processing units to the task ratio corresponding to the i-th first processing unit to obtain the first value corresponding to the i-th type of first processing units; calculates the difference between the first threshold and the task ratio corresponding to the i-th type of first processing units to obtain the second value corresponding to the i-th type of first processing units; and determines at least two groups of occupancy ratios and the task optimization parameters corresponding to each group of occupancy ratios based on the N first values and the N second values corresponding to the N types of first processing units, so as to be able to quickly and accurately determine at least two groups of occupancy ratios and the task optimization parameters corresponding to each group of occupancy ratios.
[0085] In some embodiments of the present application, when the above-mentioned N types of processing units are N sub-processing units with different performance parameters in the second processing unit, in combination with Figure 3 , such as Figure 5 shown, the above-mentioned step 102a1 can be implemented through the following step B1 and the following step B2:
[0086] Step B1: The electronic device calculates the difference between the first threshold and the second ratio corresponding to the second processing unit to obtain a third value.
[0087] In some embodiments of the present application, the above-mentioned second processing unit may be a CPU, and the N sub-processing units with different performance parameters may be different cores in the CPU.
[0088] In some embodiments of the present application, when the N types of processing units are N sub-processing units with different performance parameters in the second processing unit, the second ratio corresponding to the second processing unit is the second ratio corresponding to each sub-processing unit in the second processing unit.
[0089] In some embodiments of the processing unit of the present application, the electronic device may calculate the third value using the following formula:
[0090] n = (1 - p); (4)
[0091] where n represents the above-mentioned third value, and p represents the second ratio corresponding to the above-mentioned second processing unit.
[0092] Step B2: The electronic device determines at least two groups of occupancy ratios and the task optimization parameters corresponding to each group of occupancy ratios based on the third value and the N performance parameters.
[0093] In some embodiments of the present application, the electronic device may use the following formula to determine at least two groups of occupancy ratios and the task optimization parameters corresponding to each group of occupancy ratios:
[0094]
[0095] where Fi represents the performance parameter of the i-th sub-processing unit.
[0096] In some embodiments of the present application, the electronic device may determine a second correspondence between the task optimization parameter and the occupation ratio corresponding to each of the N sub-processing units according to the above formula (5), and then the electronic device may determine at least two groups of occupation ratios and the task optimization parameters corresponding to each group of occupation ratios based on the second correspondence.
[0097] In this way, the electronic device calculates the difference between the first threshold and the task ratio corresponding to the second processing unit to obtain a third value, and determines at least two groups of occupation ratios and the task optimization parameters corresponding to each group of occupation ratios based on the third value and the N performance parameters, so as to quickly and accurately determine at least two groups of occupation ratios and the task optimization parameters corresponding to each group of occupation ratios.
[0098] In some embodiments of the present application, in the case that the N types of processing units include M different types of first processing units and N - M sub-processing units with different performance parameters in the second processing unit, combined with Figure 3 , as Figure 6 shown, the above step 102a1 may be implemented through the following steps C1 to the following step C4:
[0099] Step C1: The electronic device calculates the ratio of the number of the j-th type of first processing unit to the first ratio corresponding to the j-th type of first processing unit to obtain the first value corresponding to the j-th type of first processing unit.
[0100] In some embodiments of the present application, j ∈ [1, M], and j is an integer.
[0101] In some embodiments of the present application, the M different types of first processing units may be different types of processing units in a multi-heterogeneous core architecture. For example, GPU, NPU, and FPGA, etc.
[0102] It should be noted that the specific calculation method of the first value corresponding to the j-th type of first processing unit may refer to the above formula (3), which will not be elaborated here in this embodiment.
[0103] Step C2: The electronic device calculates the difference between the first threshold and the task ratio corresponding to the j-th type of first processing unit to obtain the second value corresponding to the j-th type of first processing unit.
[0104] It should be noted that the specific calculation method of the second value corresponding to the j-th type of first processing unit may refer to the above formula (4), which will not be elaborated here in this embodiment.
[0105] Step C3: The electronic device calculates the difference between the first threshold and the second ratio corresponding to the second processing unit to obtain a third value.
[0106] It should be noted that the specific calculation method of the above third value can refer to the above formula (4), which will not be elaborated here in this embodiment.
[0107] Step C4: The electronic device determines at least two groups of occupancy ratios and task optimization parameters corresponding to each group of occupancy ratios based on the M first values, M second values, the third value, and N - M performance parameters corresponding to the M first processing units.
[0108] In some embodiments of the present application, the electronic device may calculate the sum of the first value corresponding to the jth first processing unit and the second value corresponding to the jth processing unit to obtain the fourth value corresponding to the jth first processing unit, and then determine the at least two groups of occupancy ratios and the task optimization parameters corresponding to each group of occupancy ratios based on the M fourth values, the third value, and N - M performance parameters corresponding to the M first processing units.
[0109] In some embodiments of the present application, the electronic device may use the following formula to determine at least two groups of occupancy ratios and task optimization parameters corresponding to each group of occupancy ratios:
[0110]
[0111] where q k represents the occupancy ratio corresponding to the kth sub - processing unit, k is an integer greater than 1 and less than M, l 1 +l 2 +...l i +...l N-M +q 1 +q 2 +q k +...q M = 1.
[0112] In some embodiments of the present application, the electronic device may determine the third correspondence relationship between the task optimization parameters, the occupancy ratios corresponding to each of the M first processing units, and the occupancy ratios corresponding to the N - M sub - processing units according to the above formula (6), and then the electronic device may determine at least two groups of occupancy ratios and task optimization parameters corresponding to each group of occupancy ratios based on the third correspondence relationship.
[0113] In some embodiments of the present application, the electronic device may also use the following formula to determine at least two groups of occupancy ratios and task optimization parameters corresponding to each group of occupancy ratios:
[0114]
[0115] where l represents the occupancy ratio corresponding to the second processing unit, l + l 1 +l 2 +...l i+...l N-M = 1.
[0116] In some embodiments of the present application, the electronic device may determine a fourth corresponding relationship between the task optimization parameter and the occupancy ratios corresponding to each of the M first processing units and the occupancy ratio corresponding to the second processing unit according to the above formula (7), and then the electronic device may determine at least two sets of occupancy ratios and the task optimization parameters corresponding to each set of occupancy ratios based on the fourth corresponding relationship.
[0117] In this way, the electronic device obtains the first value corresponding to the j-th first processing unit by calculating the ratio of the number of the j-th first processing units to the task ratio corresponding to the j-th first processing unit; calculates the difference between the first threshold and the task ratio corresponding to the j-th first processing unit to obtain the second value corresponding to the j-th first processing unit; calculates the difference between the first threshold and the task ratio corresponding to the second processing unit to obtain the third value; and determines at least two sets of occupancy ratios and the task optimization parameters corresponding to each set of occupancy ratios based on the first value, the second value, the third value, and N - M performance parameters, so as to be able to quickly and accurately determine at least two sets of occupancy ratios and the task optimization parameters corresponding to each set of occupancy ratios.
[0118] Step 102a2: The electronic device determines the occupancy ratios corresponding to the N processing units respectively as the set of occupancy ratios corresponding to the maximum task optimization parameter among the at least two sets of occupancy ratios.
[0119] In some embodiments of the present application, after the electronic device determines the at least two sets of occupancy ratios in any one of the above formula (3), the above formula (5), and formula (6), the electronic device may determine the occupancy ratios corresponding to the N processing units respectively as the set of occupancy ratios corresponding to the maximum task optimization parameter among the at least two sets of occupancy ratios.
[0120] In some embodiments of the present application, after the electronic device determines the at least two sets of occupancy ratios according to the above formula (7) and determines the occupancy ratios corresponding to the N processing units respectively as the set of occupancy ratios corresponding to the maximum task optimization parameter among the at least two sets of occupancy ratios, the electronic device may evenly divide the occupancy ratio corresponding to the second processing unit according to the number N - M of the sub-processing units in the second processing unit to obtain the occupancy ratios corresponding to each of the N - M sub-processing units.
[0121] In this way, the electronic device determines at least two sets of occupancy ratios and task optimization parameters corresponding to each set of occupancy ratios based on the first parameter; determines the set of occupancy ratios corresponding to the maximum task optimization parameter among the at least two sets of occupancy ratios as the occupancy ratios corresponding to N types of processing units respectively, can quickly and accurately determine the occupancy ratios corresponding to N types of processing units respectively, and then can reasonably allocate the computing resources required for processing the first task to N types of processing units based on the occupancy ratios corresponding to N types of processing units respectively, so that N types of processing units can execute the first task by using the computing resources required for processing the first task, thereby improving the computing efficiency of the electronic device in executing the first task.
[0122] Step 102b: The electronic device allocates the task processing resources required for processing the first task to N types of processing units based on N occupancy ratios.
[0123] In some embodiments of the present application, in combination with Figure 2 , such as Figure 7 shown, the above step 102b can be implemented by the following step 102b1 and the following step 102b2:
[0124] Step 102b1: The electronic device calculates the product of each occupancy ratio and the first amount of operations respectively to obtain N second amounts of operations.
[0125] In some embodiments of the present application, the above first amount of operations is the quantity of computing resources required for the electronic device to execute the above first task.
[0126] In some embodiments of the present application, the electronic device can calculate the product of the occupancy ratio corresponding to each type of processing unit among N types of processing units and the first amount of operations to obtain the second amount of operations corresponding to each type of processing unit among N types of processing units, that is, the above N second amounts of operations.
[0127] For example, when N is 3, the three occupancy ratios are 0.3, 0.4, and 0.3 respectively. When the first amount of operations is 170, the 3 second amounts of operations are 0.3 * 170, 0.4 * 170, and 0.3 * 170 respectively, that is, the 3 second amounts of operations are 30, 40, and 30 respectively.
[0128] Step 102b2: The electronic device allocates the task processing resources required for processing the first task to N types of processing units according to the N second amounts of operations.
[0129] In some embodiments of the present application, the electronic device allocates the task processing resources required for processing the first task to the corresponding processing unit according to the amount of operations corresponding to each type of processing unit among the N second amounts of operations.
[0130] For example, the three second operands are 30, 40, and 30 respectively. The second operand corresponding to the first type of processing unit is 30, the second operand corresponding to the second type of processing unit is 40, and the second operand corresponding to the third type of processing unit is 30. Then, the electronic device allocates 30 task processing resources required for processing the first task to the first type of processing unit, allocates 40 task processing resources required for processing the first task to the second type of processing unit, and allocates 30 task processing resources required for processing the first task to the third type of processing unit.
[0131] In this way, the electronic device calculates the product of each occupation ratio and the first operand respectively to obtain N second operands, and allocates the task processing resources required for processing the first task to N types of processing units according to the N second operands, so as to reasonably allocate the computing resources required for processing the first task to N types of processing units based on the N occupation ratios, so that the N types of processing units can execute the first task by using the computing resources required for processing the first task, thereby improving the computing efficiency of the electronic device for executing the first task.
[0132] In the task processing method provided by the embodiments of the present application, by obtaining the first parameters of N types of processing units corresponding to the first task; the first parameters are used to indicate the number of subtasks with parallel processing attributes allocated to the processing units; N is an integer greater than 1; based on the first parameters, allocate the task processing resources corresponding to the first task to N types of processing units. In this way, the electronic device can reasonably allocate the computing resources required for processing the first task to N types of processing units based on the first parameters of the N types of processing units, so that the N types of processing units can execute the first task by using the computing resources required for processing the first task, thereby improving the computing efficiency of the electronic device for executing the first task.
[0133] Next, in combination with Figures 8 to 14 , the task processing method provided by the present application will be described.
[0134] Amdahl's law is a very important empirical rule in the computer science field, proposed by Gene Amdahl in 1967. It describes the principle of improving system performance through asynchronous processing in the parallel processing of tasks. Specifically, Amdahl's law states that if a certain part of a task adopts a faster execution method, the degree of improvement in system performance will be affected by the proportion of the computing time of this improved part in the total computing time.
[0135] Amdahl's law is used to describe the limit of task performance optimization. The performance optimization parameter (i.e., the above-mentioned task optimization parameter) S is defined as the execution time before task optimization divided by the execution time after task optimization, and the performance optimization parameter characterizes the degree to which the task can be optimized.
[0136] Amdahl's Law divides a task into two parts: an optimizable part p and a non-optimizable part 1 - p, where E new is the execution time of the optimized task, and E old is the execution time before optimization. Then the task performance optimization parameter can be determined by the following formula:
[0137]
[0138] where s represents the optimization multiple.
[0139] As can be seen from formula (8), the worst case is when the optimizable part p is 0, and the best case is when 100% can be optimized. In other cases, the optimizable part is greater than 0 and less than 1.
[0140] For example, when executing a single-threaded task on a 4-core CPU, 20% of the part cannot be parallelized, and 80% of the task can be parallelized. Then the task performance optimization parameter can be calculated using the following formula:
[0141]
[0142] However, Amdahl's Law ignores the limitations in hardware and software implementation. In an actual system, the parallel capabilities of the hardware and the parallel design of the software also affect the degree of performance improvement. Especially after the addition of heterogeneous cores, the impact is greater.
[0143] This application provides a task processing method. Through steps such as data collection, performance benchmark testing, data analysis, model building, and verification, it comprehensively evaluates and optimizes the performance of multi-heterogeneous cores. Thus, when an electronic device uses multi-heterogeneous cores to execute tasks, it accurately analyzes the task performance optimization parameters. Furthermore, when the task optimization parameter reaches the maximum task optimization parameter, it allocates the computing resources required to execute the task to each processing unit in the multi-heterogeneous core architecture, thereby improving the computing efficiency of the electronic device in executing tasks.
[0144] In some embodiments of this application, when adding processing units such as heterogeneous cores MVPU and GPU in an electronic device to process task A, the task performance optimization parameter of task A can be determined by the following formula:
[0145]
[0146] where a + b + c + … = 1; a is the proportion of the CPU in task A, that is, what proportion of task A is processed by the CPU; b is the proportion of MVPU in task A, that is, what proportion of task A is processed by MVPU; c is the proportion of GPU in task A, that is, what proportion of task A is processed by GPU; p cpu represents the proportion of task A on the CPU that can be processed in parallel, and pmvpu Indicates the proportion p of task A on the MVPU that can be processed in parallel gpu Indicates the proportion s of task A on the MVPU that can be processed in parallel cpu Indicates the number s of CPUs mvpu Indicates the number of MVPUs
[0147] For example, when task A includes an image format conversion subtask and the image format conversion subtask is processed by the CPU. If the image format conversion subtask is used to indicate the conversion of an image from the RGB format to the YCbCr format, since each pixel in the image is converted using the same calculation formula Y=(77*R + 150*G + 29*B), the CPU can fully execute the image format conversion subtask in parallel, so p cpu = 1. If the image format conversion subtask includes the conversion of the image pixel format and image display, and the image pixel format conversion accounts for 60% of the image format conversion subtask and the image display accounts for 40% of the image format conversion subtask, then p cpu = 0.6
[0148] For example, as shown in Figure 8 In the calculation distribution of the ALF operator, 80% is occupied, runs on the MVPU, and runs on the small core of the MVPU. The other operators occupy 20% and run on the CPU. Then the performance optimization parameter of the ALF operator can be determined by the following formula:
[0149]
[0150] The Adaptive Loop Filt (ALF) is one of the algorithms or tools in H.266 decoding
[0151] As Figure 9 shown, when decoding 500 frames of data, 396 frames are decoded on MVPU0 and 104 frames are decoded on MVPU1. Then 208 frames can be executed in parallel by the MVPU. Therefore Assume s cpu = 2, s mvpu = 4, p cpu = 1, indicating that 20% of the part originally executed by the CPU in the ALF algorithm can be executed in parallel. Then Substitute s cpu = 2, s mvpu = 4, and p cpu = 1 into formula (11) for the following operations:
[0152]
[0153] That is, when using two CPUs for dual-thread processing, the theoretical performance optimization parameter for the ALF operator is 1.56.
[0154] In some embodiments of the present application, when using 4 CPUs for 4-thread processing and optimizing the theoretical performance parameter of the ALF operator, s cpu = 4 can be substituted into formula (11) for the following operations:
[0155]
[0156] As Figure 10 shown, the abscissa represents the number of threads, and the ordinate represents the actual measured value of the performance optimization parameter. The actual measured performance optimization parameter for dual-thread execution of the ALF operator is 1.52, which is close to the theoretical performance optimization parameter of 1.56 for dual-thread processing of the ALF operator. The actual measured performance optimization parameter for four-thread execution of the ALF operator is 2.08, which is close to the theoretical performance optimization parameter of 1.96 for 4-thread processing of the ALF operator. It can be seen that the actual measured performance optimization parameter and the theoretical optimization parameter are basically the same. Therefore, the performance optimization parameter of the task can be determined by the method of the present application.
[0157] In some embodiments of the present application, in order to incorporate the performance differences of different cores of the CPU into Amdahl's law formula, a performance factor (i.e., the above performance parameter) can be introduced for each core. Assume that for a specific workload, the performance factor of CPU core 1 is F1, the performance factor of CPU core 2 is F2, and so on. Considering the performance factors of different cores, the modified formula is as follows:
[0158]
[0159] Assume that there are 4 small cores CPU0, CPU1, CPU2, CPU3, 3 medium cores CPU4, CPU5, CPU6, and 1 large core CPU7 in the CPU. As Figure 11 shown, through testing, the performance factors of the small core, medium core, and large core based on the small core are F 小核 = 1, F 中核 = 1.34, F 大核 = 2.46;
[0160] Then, when using CPU0 and CPU4 to process the task, substitute F 小核 = 1, F 中核 = 1.34 into the above formula (12) for the following operations:
[0161]
[0162] Among them, S cpu0+cpu4Indicates the theoretical performance optimization parameters of the ALF operator when using CPU0 and CPU4 to process the ALF operator.
[0163] When using CPU0, CPU4, and CPU7 to process the ALF operator, set F 小核 = 1, F 中核 = 1.34, F 大核 = 2.46 and substitute them into the above formula (12) for the following operations:
[0164]
[0165] Among them, S cpu0+cpu4+cpu7 Indicates the theoretical performance optimization parameters of the ALF operator when using CPU0, CPU4, and CPU7 to process the ALF operator.
[0166] As Figure 12 shown, the abscissa represents the number of cores in the CPU, and the ordinate represents the actual measured value of the performance optimization parameter. When using CPU0 and CPU4 to process the ALF operator, the actually tested performance optimization parameter is 2.4, which is close to the theoretical performance optimization parameter of 2.34. When using CPU0, CPU4, and CPU7 to process the ALF operator, the actually tested performance optimization parameter is 4.34, which is close to the theoretical performance optimization parameter of 4.8. Therefore, the performance optimization parameters of the task can be determined by the method of this application.
[0167] It should be noted that considering the different requirements under different loads and the different performance and power consumption of big, medium, and small cores, different cores of the CPU can be used according to the load situation of the electronic device to improve the energy efficiency of the electronic device.
[0168] Exemplarily, during the test process of obtaining the performance factors of different cores, it can be achieved by binding specific cores through instructions respectively, such as cpu0, then testing its power consumption data, and then determining its performance factor based on the power consumption data.
[0169] In some embodiments of this application, when the electronic device uses different cores of the heterogeneous core MVPU and CPU to execute tasks, the performance optimization parameters of the task can be determined by the following formula:
[0170]
[0171] As Figure 13 shown, taking the big core as the benchmark, the performance factors of different cores of the CPU obtained by testing are: the small core F1 = 0.41, the medium core F2 = 0.54, and the big core F3 = 1. Then, when using CPU6, CPU7, and MVPU to process the ALF operator, the medium core F2 = 0.54, the big core F3 = 1, p mvpu = 0.416, scpu = 2, s mvpu = 4 and p cpu Substitute = 1 into formula (13) for the following operations:
[0172]
[0173] Among them, S cpu7+cpu6 represents the theoretical performance optimization parameter when the ALF operator is processed in a dual-threaded manner using CPU6, CPU7, and MVPU.
[0174] Exemplarily, when processing the ALF operator using CPU6, CPU7, and MVPU, the small core F1 = 0.41, the medium core F2 = 0.54, the large core, F3 = 1, p mvpu = 0.416, s cpu = 2, s mvpu = 4 and = 1 are substituted into formula (13) for the following operations:
[0175]
[0176] Among them, S cpu7+cpu6+cpu5+cpu4+cpu3+cpu2+cpu1+cpu0 represents the theoretical performance optimization parameter when the ALF operator is processed in an 8-threaded manner using CPU0, CPU1...CPU7, and MVPU.
[0177] As Figure 14 shown, the abscissa represents the number of threads, the ordinate represents the actual measured value of the performance optimization parameter. The actual measured performance optimization parameter when processing the ALF operator in a dual-threaded manner is 1.6, which is close to the theoretical performance optimization parameter of 1.46 when processing the ALF operator in a dual-threaded manner. The actual measured performance optimization parameter when processing the ALF operator in an 8-threaded manner is 1.97, which is close to the theoretical performance optimization parameter of 1.96 when processing the ALF operator in a dual-threaded manner. Therefore, the performance optimization parameter of the task can be determined by the method of this application.
[0178] In this way, when the occupation ratios corresponding to different processing units are fixed, the method provided by this application can accurately determine the performance optimization parameter of the task. Furthermore, when the performance optimization parameter reaches the maximum performance optimization parameter through the method of this application, the occupation ratios corresponding to different processing units corresponding to the maximum performance optimization parameter can be determined. Furthermore, according to the occupation ratios corresponding to different processing units, the computing resources required to execute the task can be reasonably allocated to different processing units, and the task processing efficiency can be improved.
[0179] It should be noted that the specific implementation process of the above task processing method can refer to the relevant descriptions of the above embodiments. To avoid repetition, this embodiment will not be elaborated here.
[0180] It should be noted that each of the above method embodiments, or various possible implementation manners in each method embodiment, can be executed independently, or any two or more of them can be combined with each other. It can be specifically determined according to actual usage requirements, and the embodiments of the present application do not limit this.
[0181] For the task processing method provided by the embodiments of the present application, the execution subject can be a task processing device. In the embodiments of the present application, taking the task processing device executing the task processing method as an example, the task processing device provided by the embodiments of the present application is described.
[0182] Figure 15 It is a schematic structural diagram of the task processing device provided by the embodiments of the present application. The task processing device 1500 includes: an acquisition module 1501 and an allocation module 1502.
[0183] Among them, the acquisition module 1501 is used to acquire the first parameters of N types of processing units corresponding to the first task; the first parameters are used to indicate the number of subtasks with parallel processing attributes allocated to the processing units; N is an integer greater than 1;
[0184] The allocation module 1502 is used to allocate the task processing resources corresponding to the first task to the N types of processing units based on the first parameters acquired by the acquisition module 1501.
[0185] In some embodiments of the present application, the allocation module 1502 is specifically used for:
[0186] Based on the first parameters, determine the respective occupancy ratios corresponding to the N types of processing units; the occupancy ratio is the occupancy ratio of the subtasks allocated to the processing units in the first task;
[0187] Based on the N occupancy ratios, allocate the task processing resources corresponding to the first task to the N types of processing units.
[0188] In some embodiments of the present application, the allocation module 1502 is specifically used for:
[0189] Based on the first parameters, determine at least two groups of occupancy ratios and the task optimization parameters corresponding to each group of occupancy ratios; each group of occupancy ratios includes the candidate occupancy ratios corresponding to the N types of processing units respectively;
[0190] Determine the group of occupancy ratios corresponding to the maximum task optimization parameter among the at least two groups of occupancy ratios as the occupancy ratios corresponding to the N types of processing units respectively.
[0191] In some embodiments of the present application, the N processing units include N different types of first processing units; the first parameter is the first ratio of the number of subtasks with parallel processing attributes assigned to the first processing unit to the number of subtasks assigned to the first processing unit;
[0192] The allocation module 1502 is specifically configured to:
[0193] Calculate the ratio of the number of the i-th type of first processing unit to the first ratio corresponding to the i-th type of first processing unit to obtain the first value corresponding to the i-th type of first processing unit, where i ∈ [1, N] and i is an integer;
[0194] Calculate the difference between the first threshold and the first ratio corresponding to the i-th type of first processing unit to obtain the second value corresponding to the i-th type of first processing unit;
[0195] Based on the N first values and N second values corresponding to the N types of first processing units, determine the at least two groups of occupancy ratios and the task optimization parameters corresponding to each group of occupancy ratios.
[0196] In some embodiments of the present application, the N processing units include N sub-processing units with different performance parameters in the second processing unit, and the first parameter includes the second ratio of the number of subtasks with parallel processing attributes assigned to the second processing unit to the number of subtasks assigned to the second processing unit, and the N performance parameters of the N sub-processing units;
[0197] The allocation module 1502 is specifically configured to:
[0198] Calculate the difference between the first threshold and the second ratio corresponding to the second processing unit to obtain the third value;
[0199] Based on the third value and the N performance parameters, determine the at least two groups of occupancy ratios and the task optimization parameters corresponding to each group of occupancy ratios.
[0200] In some embodiments of the present application, the N processing units include M different types of first processing units and N - M sub-processing units with different performance parameters in the second processing unit, and the first parameter includes the first ratio of the number of subtasks with parallel processing attributes assigned to the first processing unit to the number of subtasks assigned to the first processing unit, the second ratio of the number of subtasks with parallel processing attributes assigned to the second processing unit to the number of subtasks assigned to the second processing unit, and the performance parameters of each of the N - M sub-processing units, where M is an integer greater than 1 and less than N;
[0201] The allocation module 1502 is specifically configured to:
[0202] Calculate the ratio of the number of the j-th type of first processing units to the first ratio corresponding to the j-th type of first processing units to obtain the first value corresponding to the j-th type of first processing units;
[0203] Calculate the difference between the first threshold and the first ratio corresponding to the j-th type of first processing units to obtain the second value corresponding to the j-th type of first processing units;
[0204] Calculate the difference between the first threshold and the second ratio corresponding to the second processing units to obtain the third value;
[0205] Based on the M first values corresponding to the M types of first processing units, the N - M second values, the third value, and the N - M performance parameters, determine the at least two sets of occupancy ratios and the task optimization parameters corresponding to each set of occupancy ratios.
[0206] In some embodiments of the present application, the allocation module 1502 is specifically configured to:
[0207] Calculate the product of each occupancy ratio and the first amount of operations respectively to obtain N second amounts of operations, where the first amount of operations is the amount of computing resources required for the electronic device to execute the first task;
[0208] Allocate the task processing resources corresponding to the first task to the N types of processing units according to the N second amounts of operations.
[0209] In the task processing device provided in the embodiments of the present application, by obtaining the first parameters of N types of processing units corresponding to the first task; the first parameters are used to indicate the number of subtasks with parallel processing attributes allocated to the processing units; N is an integer greater than 1; and the task processing resources corresponding to the first task are allocated to the N types of processing units based on the first parameters. In this way, the electronic device can reasonably allocate the computing resources required to process the first task to the N types of processing units based on the first parameters of the N types of processing units, so that the N types of processing units can execute the first task using the computing resources required to process the first task, thereby improving the computing efficiency of the task processing device in executing the first task.
[0210] The task processing device in the embodiments of the present application can be an electronic device or a component in an electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal or other devices other than terminals. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a handheld computer, a vehicle-mounted electronic device, a mobile Internet device, an augmented reality / virtual reality device, a robot, a wearable device, a super mobile personal computer, a netbook, or a personal digital assistant, etc., and can also be a server, a network attached storage (NAS), a personal computer (PC), a television (TV), a teller machine, or a self-service machine, etc. The embodiments of the present application do not make specific limitations.
[0211] The task processing device in the embodiments of the present application can be a device with an operating system. The operating system can be an Android operating system, an iOS operating system, or other possible operating systems. The embodiments of the present application do not make specific limitations.
[0212] The task processing device provided in the embodiments of the present application can implement each process implemented by each embodiment of the above task processing method. To avoid repetition, it will not be elaborated here.
[0213] Optionally, as Figure 16 shown, the embodiments of the present application further provide an electronic device 1600, including a processor 1601 and a memory 1602. A program or instruction that can run on the processor 1601 is stored on the memory 1602. When the program or instruction is executed by the processor 1601, it implements each step of the embodiments of the above task processing method and can achieve the same technical effect. To avoid repetition, it will not be elaborated here.
[0214] It should be noted that the electronic devices in the embodiments of the present application include the above-mentioned mobile electronic devices and non-mobile electronic devices.
[0215] Figure 17 FIG. is a schematic diagram of the hardware structure of an electronic device for implementing the embodiments of the present application.
[0216] The electronic device 1700 includes, but is not limited to: a radio frequency unit 1701, a network module 1702, an audio output unit 1703, an input unit 1704, a sensor 1705, a display unit 1706, a user input unit 1707, an interface unit 1708, a memory 1709, and a processor 1710, etc.
[0217] Those skilled in the art can understand that the electronic device 1700 may further include a power supply (such as a battery) for powering each component. The power supply can be logically connected to the processor 1710 through a power management system, so as to manage functions such as charging, discharging, and power consumption management through the power management system. Figure 17 The structure of the electronic device shown in Figure 17 does not limit the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine some components, or have different component arrangements, which will not be elaborated here.
[0218] Among them, the processor 1710 is configured to obtain first parameters of N processing units corresponding to a first task; the first parameters are used to indicate the number of subtasks with parallel processing attributes assigned to the processing units; N is an integer greater than 1; and is configured to allocate task processing resources corresponding to the first task to the N processing units based on the first parameters.
[0219] In some embodiments of the present application, the processor 1710 is specifically configured to:
[0220] Based on the first parameters, determine the respective occupancy ratios corresponding to the N processing units; the occupancy ratio is the occupancy ratio of the subtasks assigned to the processing unit in the first task;
[0221] Allocate task processing resources corresponding to the first task to the N processing units based on the N occupancy ratios.
[0222] In some embodiments of the present application, the processor 1710 is specifically configured to:
[0223] Based on the first parameters, determine at least two groups of occupancy ratios and task optimization parameters corresponding to each group of occupancy ratios; each group of occupancy ratios includes candidate occupancy ratios corresponding to the N processing units respectively;
[0224] Determine a group of occupancy ratios corresponding to the maximum task optimization parameter among the at least two groups of occupancy ratios as the occupancy ratios corresponding to the N processing units respectively.
[0225] In some embodiments of the present application, the N processing units include N different types of first processing units; the first parameter is the first ratio of the number of subtasks with parallel processing attributes assigned to the first processing unit to the number of subtasks assigned to the first processing unit;
[0226] The processor 1710 is specifically configured to:
[0227] Calculate the ratio of the number of the i-th first processing unit to the first ratio corresponding to the i-th first processing unit to obtain the first value corresponding to the i-th first processing unit, where i ∈ [1, N] and i is an integer;
[0228] Calculate the difference between the first threshold and the first ratio corresponding to the i-th type of first processing unit to obtain the second value corresponding to the i-th type of first processing unit;
[0229] Based on the N first values and N second values corresponding to the N types of first processing units, determine the at least two groups of occupancy ratios and the task optimization parameters corresponding to each group of occupancy ratios.
[0230] In some embodiments of the present application, the N types of processing units include N sub-processing units with different performance parameters in the second processing unit, and the first parameter includes the second ratio of the number of sub-tasks with parallel processing attributes assigned to the second processing unit to the number of sub-tasks assigned to the second processing unit, and the N performance parameters of the N processing units;
[0231] The processor 1710 is specifically configured to:
[0232] Calculate the difference between the first threshold and the second ratio corresponding to the second processing unit to obtain the third value;
[0233] Based on the third value and the N performance parameters, determine the at least two groups of occupancy ratios and the task optimization parameters corresponding to each group of occupancy ratios.
[0234] In some embodiments of the present application, the N types of processing units include M different types of first processing units and N - M sub-processing units with different performance parameters in the second processing unit; the first parameter includes the first ratio of the number of sub-tasks with parallel processing attributes assigned to the first processing unit to the number of sub-tasks assigned to the first processing unit, the second ratio of the number of sub-tasks with parallel processing attributes assigned to the second processing unit to the number of sub-tasks assigned to the second processing unit, and the performance parameters of each of the N - M sub-processing units, where M is an integer greater than 1 and less than N;
[0235] The processor 1710 is specifically configured to:
[0236] Calculate the ratio of the number of the j-th type of first processing unit to the first ratio corresponding to the j-th type of first processing unit to obtain the first value corresponding to the j-th type of first processing unit;
[0237] Calculate the difference between the first threshold and the first ratio corresponding to the j-th type of first processing unit to obtain the second value corresponding to the j-th type of first processing unit;
[0238] Calculate the difference between the first threshold and the second ratio corresponding to the second processing unit to obtain the third value;
[0239] Based on the M first numerical values corresponding to the M first processing units, the N - M second numerical values, the third numerical value, and the N - M performance parameters, determine the at least two sets of occupancy ratios and the task optimization parameters corresponding to each set of occupancy ratios.
[0240] In some embodiments of the present application, the processor 1710 is specifically configured to:
[0241] Calculate the product of each occupancy ratio and the first amount of computation respectively to obtain N second amounts of computation, where the first amount of computation is the amount of computing resources required for the electronic device to execute the first task;
[0242] Allocate the task processing resources corresponding to the first task to the N types of processing units according to the N second amounts of computation.
[0243] In the electronic device provided in the embodiments of the present application, by obtaining the first parameters of N types of processing units corresponding to the first task; the first parameters are used to indicate the number of subtasks with parallel processing attributes allocated to the processing units; N is an integer greater than 1; and used to allocate the task processing resources corresponding to the first task to the N types of processing units based on the first parameters. In this way, the electronic device can reasonably allocate the computing resources required to process the first task to the N types of processing units based on the first parameters of the N types of processing units, so that the N types of processing units can execute the first task using the computing resources required to process the first task, thereby improving the computing efficiency of the electronic device in executing the first task.
[0244] It should be understood that in the embodiments of the present application, the input unit 1704 may include a Graphics Processing Unit (GPU) 17041 and a microphone 17042. The graphics processor 17041 processes the image data of static pictures or videos obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The display unit 1706 may include a display panel 17061, and the display panel 17061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 1707 includes at least one of a touch panel 17071 and other input devices 17072. The touch panel 17071 is also called a touch screen. The touch panel 17071 may include two parts: a touch detection device and a touch controller. The other input devices 17072 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, power on / off keys, etc.), a trackball, a mouse, and a joystick, which will not be elaborated here.
[0245] The memory 1709 can be used to store software programs and various data. The memory 1709 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data. Among them, the first storage area may store an operating system, application programs or instructions required for at least one function (such as a sound playback function, an image playback function, etc.). In addition, the memory 1709 may include a volatile memory or a non-volatile memory, or the memory 1709 may include both a volatile and a non-volatile memory. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDR SDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synch link dynamic random access memory (SLDRAM), and a direct rambus random access memory (DRRAM). The memory 1709 in the embodiments of the present application includes, but is not limited to, these and any other suitable types of memories.
[0246] The processor 1710 may include one or more processing units; optionally, the processor 1710 integrates an application processor and a modem processor. Among them, the application processor mainly processes operations related to the operating system, user interface, and application programs, etc., and the modem processor mainly processes wireless communication signals, such as a baseband processor. It can be understood that the above modem processor may not be integrated into the processor 1710 either.
[0247] The embodiments of the present application also provide a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, it implements each process of the above task processing method embodiment and can achieve the same technical effect. To avoid repetition, it will not be elaborated here.
[0248] Among them, the processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory ROM, random access memory RAM, magnetic disks, or optical discs, etc.
[0249] Another embodiment of the present application provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor. The processor is used to run programs or instructions to implement each process of the above task processing method embodiment, and can achieve the same technical effects. To avoid repetition, it will not be elaborated here.
[0250] It should be understood that the chip mentioned in the embodiments of the present application may also be referred to as a system-on-chip, system chip, chip system, or system-on-chip, etc.
[0251] The embodiments of the present application provide a computer program product. The program product is stored in a storage medium and is executed by at least one processor to implement each process of the above task processing method embodiment, and can achieve the same technical effects. To avoid repetition, it will not be elaborated here.
[0252] It should be noted that in this article, the term "including", "comprising", or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article, or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed, or further includes elements inherent to such a process, method, article, or device. Without further limitation, an element defined by the statement "including a..." does not exclude the existence of additional identical elements in the process, method, article, or device including that element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed. It may also include performing functions in a substantially simultaneous manner or in the reverse order according to the functions involved. For example, the described methods may be performed in an order different from that described, and various steps may be added, omitted, or combined. Additionally, the features described with reference to certain examples may be combined in other examples.
[0253] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-described example methods can be implemented by means of software plus a necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation. Based on such an understanding, the technical solution of the present application, in essence or the part that contributes to the prior art, can be embodied in the form of a computer software product. The computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions for causing a terminal (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present application.
[0254] The embodiments of the present application have been described above in conjunction with the accompanying drawings. However, the present application is not limited to the above specific implementation manners. The above specific implementation manners are merely illustrative and not restrictive. Under the inspiration of the present application, those of ordinary skill in the art can also make many forms without departing from the purpose of the present application and the scope protected by the claims, and all of them belong to the protection scope of the present application.
Claims
1. A task processing method, characterized in that: Applied to electronic equipment, the method comprises: Obtaining first parameters of N types of processing units corresponding to a first task; the first parameters are used to indicate the number of subtasks with a parallel processing attribute assigned to the processing unit; N is an integer greater than 1; Based on the first parameter, task processing resources corresponding to the first task are allocated to the N types of processing units.
2. The method according to claim 1, characterized in that The allocating task processing resources corresponding to the first task to the N types of processing units based on the first parameter includes: Based on the first parameter, determining the proportions corresponding to the N types of processing units respectively; the proportions are the proportions of the subtasks assigned to the processing units in the first task; Based on the N proportion values, task processing resources corresponding to the first task are allocated to the N types of processing units.
3. The method according to claim 2, characterized in that The determining, based on the first parameter, the proportions corresponding to the N types of processing units respectively includes: Based on the first parameter, determining at least two groups of proportion values and task optimization parameters corresponding to each group of proportion values; each group of proportion values includes candidate proportion values corresponding to the N types of processing units respectively; A group of proportion values corresponding to the maximum task optimization parameter among the at least two groups of proportion values is determined as the proportion values respectively corresponding to the N types of processing units.
4. The method according to claim 3, characterized in that The N types of processing units include N different types of first processing units; the first parameter is a first ratio of the number of subtasks with parallel processing attributes assigned to the first processing unit to the number of subtasks assigned to the first processing unit; The determining, based on the first parameter, at least two groups of proportion values and task optimization parameters corresponding to each group of proportion values includes: Calculate the ratio of the number of the i-th first processing unit to the first proportion corresponding to the i-th first processing unit to obtain a first value corresponding to the i-th first processing unit, i∈[1,N], and i is an integer; Calculate the difference between the first threshold and the first ratio corresponding to the i-th first processing unit to obtain a second value corresponding to the i-th first processing unit; Based on the N first values and the N second values corresponding to the N types of first processing units, the at least two groups of proportion values and the task optimization parameters corresponding to each group of proportion values are determined.
5. The method according to claim 3, characterized in that: The N types of processing units include N sub-processing units with different performance parameters in the second processing unit, the first parameter includes a second ratio of the number of sub-tasks with parallel processing attributes allocated to the second processing unit to the number of sub-tasks allocated to the second processing unit, and the N performance parameters of the N sub-processing units; The determining, based on the first parameter, at least two groups of proportion values and task optimization parameters corresponding to each group of proportion values includes: Calculate the difference between the first threshold and the second ratio corresponding to the second processing unit to obtain a third value; Based on the third value and N performance parameters, the at least two groups of proportion values and the task optimization parameters corresponding to each group of proportion values are determined.
6. The method according to claim 3, characterized in that: The N types of processing units include M different types of first processing units and NM sub-processing units with different performance parameters in the second processing unit, the first parameter includes a first ratio of the number of subtasks with parallel processing attributes assigned to the first processing unit to the number of subtasks assigned to the first processing unit, a second ratio of the number of subtasks with parallel processing attributes assigned to the second processing unit to the number of subtasks assigned to the second processing unit, and a performance parameter of each sub-processing unit in the NM sub-processing units, and M is an integer greater than 1 and less than N; The determining, based on the first parameter, at least two groups of proportion values and task optimization parameters corresponding to each group of proportion values includes: Calculate the ratio of the number of the j-th first processing unit to the first proportion corresponding to the j-th first processing unit to obtain a first value corresponding to the j-th first processing unit; Calculate the difference between the first threshold and the first ratio corresponding to the j-th first processing unit to obtain a second value corresponding to the j-th first processing unit; Calculate the difference between the first threshold and the second ratio corresponding to the second processing unit to obtain a third value; Based on the M first values and NM second values corresponding to the M first processing units, the third value and NM performance parameters, the at least two groups of proportion values and the task optimization parameters corresponding to each group of proportion values are determined.
7. The method according to claim 2, characterized in that: The allocating task processing resources corresponding to the first task to the N types of processing units based on the N proportion values includes: Calculate the product of each proportion value and the first operation amount respectively to obtain N second operation amounts, where the first operation amount is the number of computing resources required for the electronic device to perform the first task; According to the N second computation amounts, task processing resources corresponding to the first task are allocated to the N types of processing units.
8. A task processing device, characterized in that: The device comprises: An acquisition module, used for acquiring first parameters of N types of processing units corresponding to a first task; the first parameters are used to indicate the number of subtasks with parallel processing attributes assigned to the processing units; N is an integer greater than 1; An allocation module is used to allocate task processing resources corresponding to the first task to the N types of processing units based on the first parameter acquired by the acquisition module.
9. The device according to claim 8, characterized in that The allocation module is specifically used for: Based on the first parameter, determining the proportions corresponding to the N types of processing units respectively; the proportions are the proportions of the subtasks assigned to the processing units in the first task; Based on the N proportion values, task processing resources corresponding to the first task are allocated to the N types of processing units.
10. The device according to claim 9, characterized in that The allocation module is specifically used for: Based on the first parameter, determining at least two groups of proportion values and task optimization parameters corresponding to each group of proportion values; each group of proportion values includes candidate proportion values corresponding to the N types of processing units respectively; A group of proportion values corresponding to the maximum task optimization parameter among the at least two groups of proportion values is determined as the proportion values respectively corresponding to the N types of processing units.
11. The device according to claim 10, characterized in that The N types of processing units include N different types of first processing units; the first parameter is a first ratio of the number of subtasks with parallel processing attributes assigned to the first processing unit to the number of subtasks assigned to the first processing unit; The allocation module is specifically used for: Calculate the ratio of the number of the i-th first processing unit to the first proportion corresponding to the i-th first processing unit to obtain a first value corresponding to the i-th first processing unit, i∈[1,N], and i is an integer; Calculate the difference between the first threshold and the first ratio corresponding to the i-th first processing unit to obtain a second value corresponding to the i-th first processing unit; Based on the N first values and the N second values corresponding to the N types of first processing units, the at least two groups of proportion values and the task optimization parameters corresponding to each group of proportion values are determined.
12. The device according to claim 10, characterized in that The N types of processing units include N sub-processing units with different performance parameters in the second processing unit, the first parameter includes a second ratio of the number of sub-tasks with parallel processing attributes allocated to the second processing unit to the number of sub-tasks allocated to the second processing unit, and the N performance parameters of the N processing units; The allocation module is specifically used for: Calculate the difference between the first threshold and the second ratio corresponding to the second processing unit to obtain a third value; Based on the third value and N performance parameters, the at least two groups of proportion values and the task optimization parameters corresponding to each group of proportion values are determined.
13. The device according to claim 10, characterized in that The N types of processing units include M different types of first processing units and NM sub-processing units with different performance parameters in the second processing unit, the first parameter includes a first ratio of the number of subtasks with parallel processing attributes assigned to the first processing unit to the number of subtasks assigned to the first processing unit, a second ratio of the number of subtasks with parallel processing attributes assigned to the second processing unit to the number of subtasks assigned to the second processing unit, and a performance parameter of each sub-processing unit in the NM sub-processing units, and M is an integer greater than 1 and less than N; The allocation module is specifically used for: Calculate the ratio of the number of the j-th first processing unit to the first proportion corresponding to the j-th first processing unit to obtain a first value corresponding to the j-th first processing unit; Calculate the difference between the first threshold and the first ratio corresponding to the j-th first processing unit to obtain a second value corresponding to the j-th first processing unit; Calculate the difference between the first threshold and the second ratio corresponding to the second processing unit to obtain a third value; Based on the M first values and NM second values corresponding to the M first processing units, the third value and NM performance parameters, the at least two groups of proportion values and the task optimization parameters corresponding to each group of proportion values are determined.
14. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores a program or instruction that can be run on the processor, and when the program or instruction is executed by the processor, the steps of the task processing method according to any one of claims 1 to 7 are implemented.
15. A readable storage medium, characterized in that: The readable storage medium stores a program or an instruction, and when the program or the instruction is executed by the processor, the steps of the task processing method according to any one of claims 1 to 7 are implemented.