CN115309553A - Resource occupation calculation method, calculation device, equipment and storage medium - Google Patents

Resource occupation calculation method, calculation device, equipment and storage medium Download PDF

Info

Publication number
CN115309553A
CN115309553A CN202210944113.1A CN202210944113A CN115309553A CN 115309553 A CN115309553 A CN 115309553A CN 202210944113 A CN202210944113 A CN 202210944113A CN 115309553 A CN115309553 A CN 115309553A
Authority
CN
China
Prior art keywords
program
total
resource
kernel
occupied
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Withdrawn
Application number
CN202210944113.1A
Other languages
Chinese (zh)
Inventor
周连祥
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Grey Shark Technology Co ltd
Original Assignee
Nanjing Thunder Shark Information Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nanjing Thunder Shark Information Technology Co ltd filed Critical Nanjing Thunder Shark Information Technology Co ltd
Priority to CN202210944113.1A priority Critical patent/CN115309553A/en
Publication of CN115309553A publication Critical patent/CN115309553A/en
Withdrawn legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/3024Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a central processing unit [CPU]

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Quality & Reliability (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention provides a resource occupation calculation method, which comprises the steps of providing a CPU with a plurality of kernels, and acquiring the calculation capacity of each kernel; presetting total statistical time length, and sequentially acquiring the maximum frequency of each kernel in the total statistical time length; acquiring a plurality of program segments in the program to be calculated, and sequentially acquiring the occupation duration of each program segment and the scheduling frequency of the program segment in the kernel where the program segment is located; acquiring a resource occupation ratio according to the occupation duration, the scheduling frequency, the total statistical duration and the maximum frequency; calculating and acquiring the occupied resources of the program according to the resource proportion and the computing capacity; and calculating the total resource occupancy rate of the program to be calculated according to all the occupied resources of the program and the calculation capacity. The accuracy of the resource occupied by the calculation program is improved. The invention also provides a computing device, equipment and a storage medium for realizing the computing method of the resource occupation.

Description

Resource occupation calculation method, calculation device, equipment and storage medium
Technical Field
The present invention relates to the field of computers, and in particular, to a method, an apparatus, a device, and a storage medium for calculating resource occupation.
Background
CPU occupancy is an important indicator in computer hardware. In the prior art, the resource occupancy rate of a program in a CPU is calculated according to the duration of the program, for example, the resource occupancy rate of the CPU is calculated by a top command commonly used in a Linux operating system, the top command is a performance analysis tool commonly used in Linux, the resource occupancy state of each process in the system can be displayed in real time, and the method is similar to a task manager of Windows. The method is to calculate the proportion of the occupied time of the program in the total time length to obtain the CPU resource occupancy rate.
However, when there are multiple cores in the CPU, the computation capability of each core is different, and the maximum frequency of the core is also different, and the CPU resource occupancy obtained by the above method for calculating the proportion of the occupied time of the computation program in the total duration is not accurate enough, and the computation accuracy is low.
Disclosure of Invention
In order to overcome the technical defects, the invention aims to provide a resource occupation calculation method, a calculation device, equipment and a storage medium, so as to solve the problem of inaccurate calculation of the CPU resource occupation rate in the prior art.
The invention discloses a method for calculating resource occupation, which comprises the following steps:
providing a CPU with a plurality of kernels, and acquiring the computing capacity of each kernel;
presetting total statistical time length, and sequentially acquiring the maximum frequency of each core in the total statistical time length, wherein at least one program to be calculated is in the total statistical time length;
acquiring a plurality of program segments in the program to be calculated, wherein the program segments are positioned in the cores, and acquiring the occupation duration of each program segment and the scheduling frequency of the program segment in the core in which the program segment is positioned in sequence;
acquiring a resource occupation ratio according to the occupation duration, the scheduling frequency, the total statistical duration and the maximum frequency;
calculating and acquiring the occupied resources of the program according to the resource proportion and the computing capacity;
and calculating the total resource occupancy rate of the program to be calculated according to all the occupied resources of the program and the calculation capacity.
Preferably, the step of obtaining the resource occupation ratio according to the occupation duration, the scheduling frequency, the total statistical duration and the maximum frequency, and calculating the resource occupation ratio of the obtaining program according to the resource occupation ratio and the computing power includes:
and performing multiplication operation on the occupied time and the scheduling frequency to obtain a first multiplication value, performing multiplication operation on the total statistical time and the maximum frequency to obtain a second multiplication value, performing division operation on the first multiplication value and the second multiplication value to obtain the resource occupation ratio, and performing multiplication operation on the resource occupation ratio and the computing capacity to obtain the program occupied resource.
Preferably, the step of calculating the total resource occupancy rate of the program to be calculated according to all the occupied resources of the program and the calculation capacity includes:
acquiring a first total occupied resource according to all the program occupied resources;
acquiring total computing capacity according to the computing capacity of all the kernels;
and performing division operation on the total occupied resources of the programs and the total computing capacity to obtain the total resource occupancy rate.
Preferably, the step of obtaining a first total occupied resource according to all the occupied resources of the program, and obtaining a total computing power according to the computing power of all the cores includes:
and calculating and acquiring the program occupied resources of each program segment in the kernel of each program segment in sequence, performing summation operation on all the program occupied resources to acquire the first total occupied resources, and performing summation operation on the computing capacity of all the kernels to acquire the total computing capacity.
Preferably, the step of calculating the occupied resource of the acquisition program according to the resource ratio and the computing power comprises:
the method comprises the steps of calculating the sum of the resource occupation ratios of all program segments in each kernel in sequence to obtain a single-core resource occupation ratio, performing multiplication operation on the single-core resource occupation ratio in each kernel and the calculation capacity of the kernel to obtain single-core program occupation resources, and performing summation operation on all the single-core program occupation resources to obtain the first total occupation resource.
Preferably, the step of calculating the total resource occupancy rate of the program to be calculated according to the occupied resources of all the programs and the calculation capacity includes:
grouping a plurality of kernels of the CPU to obtain m groups of kernel groups, wherein each group of kernel group at least comprises one kernel, the computing power of all kernels in each group of kernel group is the same, and the maximum frequency of all kernels in each group of kernel group is the same, wherein m is a positive integer greater than 1, and m is less than or equal to the total number of kernels of the CPU;
sequentially calculating all the program occupied resources in each group of kernel groups to obtain the kernel group program occupied resources;
performing summation operation on all the occupied resources of the kernel group program to obtain a second total occupied resource;
performing a summation operation on the computing power of all the cores to obtain total computing power;
performing a division operation on the second total occupied resources and the total computing capacity to obtain the total resource occupancy.
Preferably, the step of sequentially calculating all the program occupied resources in each kernel group to obtain the kernel group program occupied resources includes:
performing multiplication operation on the occupation duration and the scheduling frequency of each program fragment to obtain a third multiplication value;
sequentially acquiring the third multiplication values corresponding to all program segments in each group of kernel groups, and sequentially performing summation operation on all the third multiplication values in each group of kernel groups to acquire kernel group summation values;
sequentially multiplying the total statistical duration and the computing power and the execution operation of each group of kernel groups to obtain a plurality of fourth multiplication values;
sequentially executing division operation on the kernel group summation value of each kernel group and the fourth multiplication value of the kernel group to obtain a kernel group proportion value;
and sequentially executing multiplication operation on the kernel group proportion value of each kernel group and the computing capacity of the kernel group to acquire the occupied resource of the kernel group program.
The present invention also provides a computing device comprising:
the first acquisition module is used for acquiring the computing power of a plurality of kernels in the CPU;
the second acquisition module is used for presetting total statistical time length and sequentially acquiring the maximum frequency of each kernel in the total statistical time length, wherein at least one program to be calculated is in the total statistical time length;
a third obtaining module, configured to obtain a plurality of program segments in the program to be computed, where the program segments are located in the cores, and sequentially obtain an occupied duration of each program segment and a scheduling frequency of the program segment in the core where the program segment is located;
a first calculating module, configured to obtain a resource occupation ratio according to the occupation duration, the scheduling frequency, the total statistical duration, and the maximum frequency, and calculate an occupied resource of an acquiring program according to the resource occupation ratio and the calculating capability;
and the second calculation module is used for calculating the total resource occupancy rate of the program to be calculated according to all the occupied resources of the program and the calculation capacity.
The invention also provides equipment comprising the computing device.
The invention also provides a storage medium on which a computer program is stored, which, when executed by a processor, implements the method of calculating the occupation of resources.
After the technical scheme is adopted, compared with the prior art, the invention has the following beneficial effects:
acquiring the computing power of each kernel, the occupation time of each program segment of the maximum frequency of each kernel in the total statistical time and the scheduling frequency of the program segment in the kernel, and computing and acquiring the program occupation resources according to the occupation time, the scheduling frequency, the total statistical time, the maximum frequency and the computing power; the difference of the computing capacity of each core is considered, and the accuracy of the occupied resources of the computing program is improved, so that the computing result of the total resource occupancy rate of the program to be computed according to the occupied resources of all the programs is more accurate, the accuracy and the reliability of the computing of the CPU resource occupancy rate are improved, the resource occupancy rate of each core can be accurately computed due to the fact that the resource occupancy rate of the CPU is more accurately computed, and data support is provided for the resource allocation of each core; the residual space of the CPU can be calculated according to the resource occupancy rate of the CPU, and more effective data and evidence are provided for application scenes such as distribution and optimization of system resources, positioning and processing of program problems and the like.
Drawings
Fig. 1 is a flowchart of a method for calculating resource occupation according to a first embodiment of the present invention;
FIG. 2 is a flowchart illustrating a method for calculating a total resource occupancy rate of a program to be calculated according to all occupied resources of the program according to an embodiment of the present invention;
FIG. 3 is a flowchart illustrating a second embodiment of the present invention, wherein the total resource occupancy rate of a program to be calculated is calculated according to all occupied resources of the program;
fig. 4 is a schematic structural diagram of a computing device according to an embodiment of the invention.
Reference numerals are as follows: 1-a first acquisition module; 2-a second acquisition module; 3-a third obtaining module; 4-a first calculation module; 5-a second calculation module.
Detailed Description
The advantages of the invention are further illustrated by the following detailed description of the preferred embodiments in conjunction with the drawings.
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. The following description refers to the accompanying drawings in which the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the disclosure, as detailed in the appended claims.
The terminology used in the present disclosure is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. As used in this disclosure and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
It is to be understood that although the terms first, second, third, etc. may be used herein to describe various information, such information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, first information may also be referred to as second information, and similarly, second information may also be referred to as first information, without departing from the scope of the present disclosure. The word "if," as used herein, may be interpreted as "at … …" or "at … …" or "in response to a determination," depending on the context.
In the description of the present invention, it is to be understood that the terms "longitudinal", "lateral", "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", and the like, indicate orientations or positional relationships based on those shown in the drawings, and are used merely for convenience of description and for simplicity of description, and do not indicate or imply that the referenced devices or elements must have a particular orientation, be constructed in a particular orientation, and be operated, and thus, are not to be construed as limiting the present invention.
In the description of the present invention, unless otherwise specified and limited, it is to be noted that the terms "mounted," "connected," and "connected" are to be interpreted broadly, and may be, for example, a mechanical connection or an electrical connection, a communication between two elements, a direct connection, or an indirect connection via an intermediate medium, and specific meanings of the terms may be understood by those skilled in the art according to specific situations.
In the following description, suffixes such as "module", "component", or "unit" used to denote elements are used only for facilitating the explanation of the present invention, and have no specific meaning in themselves. Thus, "module" and "component" may be used in a mixture.
Example one
The embodiment of the invention discloses a method for calculating resource occupation, which comprises the following steps with reference to fig. 1:
s1: providing a CPU with a plurality of cores, and acquiring the computing power (CPU _ capacity) of each core;
in some embodiments, the computing power of each core is provided by a chip vendor, and may be obtained by a query method, and may be input into the step of the resource occupation computing method of the present invention by inputting or copying parameters built in the CPU.
S2: presetting total statistical time length, and sequentially acquiring the maximum frequency of each kernel in the total statistical time length, wherein at least one program to be calculated is in the total statistical time length;
s3: acquiring a plurality of program segments in the program to be calculated, wherein the program segments are positioned in the cores, and acquiring the occupation duration of each program segment and the scheduling frequency of the program segment in the core in which the program segment is positioned in sequence;
in some embodiments, the scheduling frequency is the frequency used by the kernel when scheduling the program fragment.
S4: acquiring a resource occupation ratio according to the occupation duration, the scheduling frequency, the total statistical duration and the maximum frequency, and calculating and acquiring program occupation resources according to the resource occupation ratio and the computing power;
s5: and calculating the total resource occupancy rate of the program to be calculated according to all the occupied resources of the program and the calculation capacity.
As a preferred embodiment of the present invention, in step S4, the step of obtaining a resource occupation ratio according to the occupation duration, the scheduling frequency, the total statistical duration, and the maximum frequency, and calculating an occupation resource of an obtaining program according to the resource occupation ratio and the computing power includes:
and performing multiplication operation on the occupied time and the scheduling frequency to obtain a first multiplication value, performing multiplication operation on the total statistical time and the maximum frequency to obtain a second multiplication value, performing division operation on the first multiplication value and the second multiplication value to obtain the resource occupation ratio, and performing multiplication operation on the resource occupation ratio and the computing capacity to obtain the program occupied resource. .
As a preferred embodiment of the present invention, referring to fig. 2, in the step S5, the step of calculating the total resource occupancy rate of the program to be calculated according to all the occupied program resources and the calculation capacity includes:
s501: acquiring a first total occupied resource according to all the program occupied resources;
s502: acquiring total computing capacity according to the computing capacity of all the kernels;
s503: and performing division operation on the total occupied resources of the programs and the total computing capacity to obtain the total resource occupancy rate.
In some embodiments, in the step S501 and the step S502, the step of obtaining a first total occupied resource according to all the program occupied resources and obtaining a total computing power according to the computing power of all the cores includes:
and sequentially calculating and acquiring the program occupied resources of each program fragment in the kernel of the program fragment, performing summation operation on all the program occupied resources to acquire the first total occupied resources, and performing summation operation on the computing capacity of all the kernels to acquire the total computing capacity.
In a first embodiment of the present invention, the specific steps of calculating the resource occupied by the acquiring program according to the resource proportion and the computing power are as follows:
calculating formula for calculating resource ratio of single program segment:
Figure BDA0003784672100000061
wherein, rs is the resource proportion of a single program segment, dur is the occupied duration, freq is the scheduling frequency, dur × freq is the first multiplication value, full _ dur is the total statistical duration, max _ freq is the maximum frequency of the kernel, and full _ dur × max _ freq is the second multiplication value;
the calculation formula for calculating the occupied resources of the program of a single program segment is as follows:
Ri=Rs×cap
ri is the occupied resource of the program, rs is the resource proportion of a single program fragment, and cap is the computing capacity of the kernel where the single program fragment is located.
And the calculation formula for calculating the total resource occupancy rate of the program to be calculated according to all the occupied resources of the program and the calculation capacity is as follows:
R=sum(Ri);
wherein, R is a first total occupied resource, that is, a resource occupied by all programs in the total statistical duration in the kernel, and sum (Ri) is a sum of all program fragments in the CPU.
In other embodiments, in step S501, the step of calculating, according to the resource proportion and the computing power, resources occupied by the acquisition program includes:
the method comprises the steps of calculating the sum of the resource occupation ratios of all program segments in each kernel in sequence to obtain a single-core resource occupation ratio, performing multiplication operation on the single-core resource occupation ratio in each kernel and the calculation capacity of the kernel to obtain single-core program occupation resources, and performing summation operation on all the single-core program occupation resources to obtain the first total occupation resource.
In some specific embodiments, the calculation formula for the resource occupied by the single-core program is obtained by sequentially calculating all the resources occupied by the program in each core as follows:
Figure BDA0003784672100000071
wherein n and i are positive integers, n is greater than 1,n and is the number of cores of the CPU, k is less than or equal to n, ri (k) represents the resource occupied by the single-core program of the kth core, cap (k) represents the computing capacity of the kth core, i represents that i program fragments exist in the core, duri represents the occupied duration of the ith program fragment in the kth core, freqi represents the scheduling frequency of the ith program fragment in the kth core,
Figure BDA0003784672100000072
the sum operation of the occupation time and the scheduling frequency of all the program segments in the kth core is shown.
The calculation formula for performing summation operation on all the resources occupied by the single-core program to obtain the first total occupied resource is as follows:
Figure BDA0003784672100000073
wherein Ri (n) represents that the single-core program of the nth core occupies resources,
Figure BDA0003784672100000074
and the sum operation is performed on the resource occupied by the single-core programs of all the cores, and R represents the first total occupied resource.
In some embodiments, the calculation formula for calculating the total resource occupancy rate of the program to be calculated according to all the occupied resources of the program and the calculation capacity is as follows:
Figure BDA0003784672100000075
wherein, R is the first total occupied resource, namely the resource occupied by all programs in the total statistical duration in the kernel; sum (Ri) is the sum of all program fragments in the CPU; r _ occupancy is the total resource occupancy; sum (cap) is the sum of the computation power of all cores in the CPU, i.e., the total computation power.
The method has the advantages that the resource occupation condition of the program in each single core is calculated, so that data support is provided for resource allocation and calling of the cores, and the task optimization or allocation of a certain core is facilitated.
Example two
The second embodiment of the invention discloses a method for calculating resource occupation, which comprises the following steps with reference to fig. 1:
s1: providing a CPU with a plurality of kernels, and acquiring the computing capacity of each kernel;
s2: presetting total statistical time length, and sequentially acquiring the maximum frequency of each core in the total statistical time length, wherein at least one program to be calculated is in the total statistical time length;
s3: acquiring a plurality of program segments in the program to be calculated, wherein the program segments are positioned in the cores, and acquiring the occupation duration of each program segment and the scheduling frequency of the program segment in the core in which the program segment is positioned in sequence;
s4: acquiring a resource occupation ratio according to the occupation duration, the scheduling frequency, the total statistical duration and the maximum frequency, and calculating and acquiring program occupation resources according to the resource occupation ratio and the computing power;
s5: and calculating the total resource occupancy rate of the program to be calculated according to all the occupied resources of the program and the calculation capacity.
Referring to fig. 3, in some embodiments, in the step S5, the step of calculating the total resource occupancy rate of the program to be calculated according to the occupied resources of all the programs includes:
s511: grouping a plurality of kernels of the CPU to obtain m groups of kernel groups, wherein each group of kernel group at least comprises one kernel, the computing power of all kernels in each group of kernel group is the same, and the maximum frequency of all kernels in each group of kernel group is the same, wherein m is a positive integer greater than 1, and m is less than or equal to the total number of kernels of the CPU;
in some specific embodiments, 8 cores in the CPU are numbered and grouped according to 0 to 7, the cores numbered 0, 1, 2, and 4 are set as a first group of cores, and the computing power of 4 cores of the first group of cores is the same; setting the kernels numbered 4, 5 and 6 as a second group of kernel groups, wherein the computing power of 3 kernels of the second group of kernel groups is the same; setting the kernel group with the number of 7 as a third group of kernel groups, wherein the computing power of the third group of kernel groups is the same; wherein the computing power of the third set of core groups is greater than the computing power of the second set of core groups, which is greater than the computing power of the first set of core groups.
S512: sequentially calculating all program occupied resources of each kernel group to obtain the kernel group program occupied resources;
s513: performing summation operation on all the occupied resources of the kernel group program to obtain a second total occupied resource;
s514: performing a summation operation on the computing power of all the cores to obtain total computing power;
s515: performing a division operation on the second total occupied resources and the total computing capacity to obtain the total resource occupancy.
As a preferred embodiment of the present invention, in step S512, the step of sequentially calculating all the program occupied resources in each kernel group to obtain the kernel group program occupied resources includes:
performing multiplication operation on the occupation duration and the scheduling frequency of each program fragment to obtain a third multiplication value;
sequentially acquiring the third multiplication values corresponding to all the program segments in each group of the kernel groups, and sequentially performing summation operation on all the third multiplication values in each group of the kernel groups to acquire kernel group summation values;
sequentially multiplying the total statistical duration and the computing power and the execution operation of each group of kernel groups to obtain a plurality of fourth multiplication values;
sequentially executing division operation on the kernel group summation value of each kernel group and the fourth multiplication value of the kernel group to obtain a kernel group proportion value;
and sequentially performing multiplication operation on the kernel group proportion value of each kernel group and the computing capacity of the kernel group to acquire the kernel group program occupied resource.
In some embodiments, the calculation formula for calculating the total resource occupancy rate of the program to be calculated according to the resource occupied by all the programs is as follows:
Figure BDA0003784672100000091
Figure BDA0003784672100000092
Figure BDA0003784672100000093
wherein m, k and j are positive integers, m is greater than 1,m and is the total number of the kernel group, k is less than or equal to m, ri (k) represents that the kernel group program of the kth kernel occupies resources, cap (k) represents the computing capacity of the kth kernel group, j represents that j program fragments exist in the kth kernel group, durj represents the occupation duration of the jth program fragment, freqj represents the scheduling frequency of the jth program fragment,
Figure BDA0003784672100000094
the sum operation is performed on the occupied time and the scheduling frequency of all the program segments in the mth kernel group;
Figure BDA0003784672100000095
the sum operation is performed on the single-core program occupied resources of all the core groups, and R1 represents a second total occupied resource;
Figure BDA0003784672100000096
the calculation capability of all the kernel groups is summed, namely the total calculation capability; r _ occupancy is the total resource occupancy.
The method has the advantages that each kernel group is obtained after being grouped, calculation is carried out by taking each kernel group as a unit, and because the calculation capacity and the maximum frequency of all the kernels in each kernel group are the same, compared with the calculation of resources occupied by each program and the calculation of resources occupied by each kernel program, the method greatly saves calculation steps, thereby improving the calculation efficiency, saving the calculation resources and the calculation power consumption, and improving the efficiency of obtaining the total resource occupancy rate. The resource occupied by the kernel group program is calculated, and data support is provided for reasonable task allocation and optimization of each kernel group with the same calculation power.
The present invention also provides a computing apparatus, referring to fig. 4, including:
the first acquisition module 1 is used for acquiring the computing power of a plurality of kernels in the CPU;
the second obtaining module 2 is configured to preset a total statistical time length, and sequentially obtain a maximum frequency of each core within the total statistical time length, where at least one program to be calculated is within the total statistical time length;
a third obtaining module 3, configured to obtain a plurality of program segments in the program to be computed, where the program segments are located in the cores, and sequentially obtain an occupied duration of each program segment and a scheduling frequency of the program segment in the core where the program segment is located;
a first calculating module 4, configured to obtain a resource occupation ratio according to the occupation duration, the scheduling frequency, the total statistical duration, and the maximum frequency, and calculate an occupied resource of an acquiring program according to the resource occupation ratio and the calculating capability;
and the second calculating module 5 is used for calculating the total resource occupancy rate of the program to be calculated according to all the occupied resources of the program and the calculating capacity.
In the first embodiment of the present invention, the first obtaining module 1, the second obtaining module 2, and the third obtaining module 3 are detecting devices or detecting circuits for detecting parameters, such as the maximum computing power frequency of a plurality of cores of a CPU, the occupied time of a program segment, and the scheduling frequency of the program segment in the core where the program segment is located.
In some embodiments, the first calculating module 4 and the second calculating module 5 are calculating circuits or calculators, and are configured to perform mathematical operations on a plurality of parameters of the CPUs acquired by the first acquiring module 1 and the second acquiring module 2, so as to obtain a final total resource occupancy rate of the program to be calculated.
The step of the first calculating module 4 obtaining the resource occupation ratio according to the occupation duration, the scheduling frequency, the total statistical duration and the maximum frequency, and calculating the resource occupation ratio of the obtaining program according to the resource occupation ratio and the calculating capacity includes:
and performing multiplication operation on the occupied time and the scheduling frequency to obtain a first multiplication value, performing multiplication operation on the total statistical time and the maximum frequency to obtain a second multiplication value, performing division operation on the first multiplication value and the second multiplication value to obtain the resource occupation ratio, and performing multiplication operation on the resource occupation ratio and the computing capacity to obtain the program occupied resource.
The step of calculating, by the second calculation module 5, the total resource occupancy of the program to be calculated according to all the occupied resources of the program includes:
acquiring a first total occupied resource according to all the program occupied resources;
acquiring total computing capacity according to the computing capacity of all the kernels;
and performing division operation on the total occupied resources of the programs and the total computing capacity to obtain the total resource occupancy rate.
In some embodiments, the step of obtaining a first total occupied resource according to all the program occupied resources and obtaining a total computing power according to the computing power of all the cores includes:
and sequentially calculating and acquiring the program occupied resources of each program fragment in the kernel of the program fragment, performing summation operation on all the program occupied resources to acquire the first total occupied resources, and performing summation operation on the computing capacity of all the kernels to acquire the total computing capacity.
In other embodiments, the step of calculating, by the second calculating module 5, the resource occupied by the acquiring program according to the resource proportion and the computing power includes:
the method comprises the steps of calculating the sum of the resource occupation ratios of all program segments in each kernel in sequence to obtain a single-core resource occupation ratio, performing multiplication operation on the single-core resource occupation ratio in each kernel and the calculation capacity of the kernel to obtain single-core program occupation resources, and performing summation operation on all the single-core program occupation resources to obtain the first total occupation resource.
In a second embodiment of the present invention, the step of calculating, by the second calculation module 5, the total resource occupancy rate of the program to be calculated according to the occupied resources of all the programs and the calculation capacity includes:
grouping a plurality of kernels of the CPU to obtain m groups of kernel groups, wherein each group of kernel groups at least comprises one kernel, the computing power of all the kernels in each group of kernel groups is the same, and the maximum frequency of all the kernels in each group of kernel groups is the same, wherein m is a positive integer greater than 1, and m is less than or equal to the total number of the kernels of the CPU;
sequentially calculating all program occupied resources in each group of kernel groups to obtain the kernel group program occupied resources;
performing summation operation on all the occupied resources of the kernel group program to obtain a second total occupied resource;
performing a summation operation on the computing power of all the cores to obtain a total computing power;
and performing division operation on the second total occupied resource and the total computing capacity to obtain the total resource occupancy rate.
In some specific embodiments, the step of sequentially calculating the resources occupied by all the programs in each kernel group to obtain the resources occupied by the programs in the kernel group includes:
performing a multiplication operation on the occupation duration and the scheduling frequency of each program segment to obtain a third multiplication value;
sequentially acquiring the third multiplication values corresponding to all the program segments in each group of kernel groups, and sequentially performing summation operation on all the third multiplication values in each group of kernel groups to acquire kernel group summation values;
sequentially multiplying the total statistical duration and the computing power and the execution operation of each group of kernel groups to obtain a plurality of fourth multiplication values;
sequentially executing division operation on the kernel group summation value of each kernel group and the fourth multiplication value of the kernel group to obtain a kernel group proportion value;
and sequentially executing multiplication operation on the kernel group proportion value of each kernel group and the computing capacity of the kernel group to acquire the occupied resource of the kernel group program.
The invention also provides equipment comprising the computing device.
The invention also provides a storage medium on which a computer program is stored, which, when executed by a processor, implements the method of calculating the occupation of resources.
After the technical scheme is adopted, compared with the prior art, the invention has the following advantages:
acquiring the computing power of each kernel, the occupation time of each program segment of the maximum frequency of each kernel in the total statistical time and the scheduling frequency of the program segment in the kernel, and computing and acquiring the program occupation resources according to the occupation time, the scheduling frequency, the total statistical time, the maximum frequency and the computing power; the difference of the computing capacity of each core is considered, and the accuracy of the occupied resources of the computing program is improved, so that the computing result of the total resource occupancy rate of the program to be computed according to the occupied resources of all the programs is more accurate, the accuracy and the reliability of the computing of the CPU resource occupancy rate are improved, the resource occupancy rate of each core can be accurately computed due to the fact that the resource occupancy rate of the CPU is more accurately computed, and data support is provided for the resource allocation of each core; the residual space of the CPU can be calculated according to the resource occupancy rate of the CPU, and more effective data and evidence are provided for application scenes such as distribution and optimization of system resources, positioning and processing of program problems and the like.
In some embodiments, the device is an electronic terminal device with a plurality of cores, including but not limited to a desktop computer, a notebook computer, a tablet computer, a mobile phone, and other intelligent terminals with multi-core CPUs.
The smart terminal may be implemented in various forms. For example, the terminal described in the present invention may include an intelligent terminal such as a mobile phone, a smart phone, a notebook computer, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a navigation device, and the like, and a fixed terminal such as a digital TV, a desktop computer, and the like. In the following, it is assumed that the terminal is a smart terminal. However, it will be understood by those skilled in the art that the configuration according to the embodiment of the present invention can be applied to a fixed type terminal in addition to elements particularly used for moving purposes.
It should be noted that the embodiments of the present invention have been described in a preferred embodiment and not limited to the embodiments, and those skilled in the art may modify and modify the above-disclosed embodiments to equivalent embodiments without departing from the scope of the present invention.

Claims (10)

1. A method for calculating resource occupation, comprising the steps of:
providing a CPU with a plurality of kernels, and acquiring the computing power of each kernel;
presetting total statistical time length, and sequentially acquiring the maximum frequency of each kernel in the total statistical time length, wherein at least one program to be calculated is in the total statistical time length;
acquiring a plurality of program segments in the program to be calculated, wherein the program segments are positioned in the cores, and acquiring the occupation duration of each program segment and the scheduling frequency of the program segment in the core in which the program segment is positioned in sequence;
acquiring a resource occupation ratio according to the occupation duration, the scheduling frequency, the total statistical duration and the maximum frequency;
calculating and acquiring the occupied resources of the program according to the resource proportion and the computing capacity;
and calculating the total resource occupancy rate of the program to be calculated according to all the occupied resources of the program and the calculation capacity.
2. The method according to claim 1, wherein the step of calculating the resource occupied by the acquiring program according to the resource proportion and the computing power comprises:
and performing multiplication operation on the occupied time and the scheduling frequency to obtain a first multiplication value, performing multiplication operation on the total statistical time and the maximum frequency to obtain a second multiplication value, performing division operation on the first multiplication value and the second multiplication value to obtain the resource occupation ratio, and performing multiplication operation on the resource occupation ratio and the computing capacity to obtain the program occupied resource.
3. The method for calculating resource occupation according to claim 2, wherein the step of calculating the total resource occupation rate of the programs to be calculated according to all the occupied program resources and the calculation capacity comprises:
acquiring a first total occupied resource according to all the program occupied resources;
acquiring total computing capacity according to the computing capacity of all the kernels;
and performing division operation on the total occupied resources of the programs and the total computing capacity to obtain the total resource occupancy rate.
4. The method according to claim 3, wherein the step of obtaining a first total occupied resource according to all the occupied resources of the program and obtaining a total computing power according to the computing power of all the cores comprises:
and calculating and acquiring the program occupied resources of each program segment in the kernel of each program segment in sequence, performing summation operation on all the program occupied resources to acquire the first total occupied resources, and performing summation operation on the computing capacity of all the kernels to acquire the total computing capacity.
5. The method of claim 3, wherein the step of calculating the resource occupied by the acquisition program based on the resource occupancy and the computing power comprises:
the method comprises the steps of calculating the sum of the resource occupation ratios of all program segments in each kernel in sequence to obtain a single-core resource occupation ratio, performing multiplication operation on the single-core resource occupation ratio in each kernel and the calculation capacity of the kernel to obtain single-core program occupation resources, and performing summation operation on all the single-core program occupation resources to obtain the first total occupation resource.
6. The method for calculating resource occupation according to claim 1, wherein the step of calculating the total resource occupation rate of the programs to be calculated according to all the occupied program resources and the calculation capacity comprises:
grouping a plurality of kernels of the CPU to obtain m groups of kernel groups, wherein each group of kernel group at least comprises one kernel, the computing power of all kernels in each group of kernel group is the same, and the maximum frequency of all kernels in each group of kernel group is the same, wherein m is a positive integer greater than 1, and m is less than or equal to the total number of kernels of the CPU;
sequentially calculating all the program occupied resources in each group of kernel groups to obtain the kernel group program occupied resources;
performing summation operation on all the occupied resources of the kernel group program to obtain a second total occupied resource;
performing a summation operation on the computing power of all the cores to obtain total computing power;
and performing division operation on the second total occupied resource and the total computing capacity to obtain the total resource occupancy rate.
7. The method of claim 6, wherein the step of sequentially calculating all the program occupied resources in each kernel group to obtain the kernel group program occupied resources comprises:
performing multiplication operation on the occupation duration and the scheduling frequency of each program fragment to obtain a third multiplication value;
sequentially acquiring the third multiplication values corresponding to all program segments in each group of kernel groups, and sequentially performing summation operation on all the third multiplication values in each group of kernel groups to acquire kernel group summation values;
sequentially multiplying the total statistical duration and the computing power and the execution operation of each group of kernel groups to obtain a plurality of fourth multiplication values;
sequentially executing division operation on the kernel group summation value of each kernel group and the fourth multiplication value of the kernel group to obtain a kernel group proportion value;
and sequentially executing multiplication operation on the kernel group proportion value of each kernel group and the computing capacity of the kernel group to acquire the occupied resource of the kernel group program.
8. A computing device, comprising:
the first acquisition module is used for acquiring the computing power of a plurality of kernels in the CPU;
the second obtaining module is used for presetting total statistical time length and sequentially obtaining the maximum frequency of each core in the total statistical time length, wherein at least one program to be calculated is in the total statistical time length;
a third obtaining module, configured to obtain a plurality of program segments in the program to be computed, where the program segments are located in the cores, and sequentially obtain an occupied duration of each program segment and a scheduling frequency of the program segment in the core where the program segment is located;
a first calculating module, configured to obtain a resource occupation ratio according to the occupation duration, the scheduling frequency, the total statistical duration, and the maximum frequency, and calculate an occupied resource of an acquiring program according to the resource occupation ratio and the calculating capability;
and the second calculation module is used for calculating the total resource occupancy rate of the program to be calculated according to all the occupied resources of the program and the calculation capacity.
9. An apparatus comprising the computing device of claim 8.
10. A storage medium having stored thereon a computer program, characterized in that the computer program, when executed by a processor, implements the method of calculating resource usage according to any one of claims 1-7.
CN202210944113.1A 2022-08-05 2022-08-05 Resource occupation calculation method, calculation device, equipment and storage medium Withdrawn CN115309553A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210944113.1A CN115309553A (en) 2022-08-05 2022-08-05 Resource occupation calculation method, calculation device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210944113.1A CN115309553A (en) 2022-08-05 2022-08-05 Resource occupation calculation method, calculation device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115309553A true CN115309553A (en) 2022-11-08

Family

ID=83860732

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210944113.1A Withdrawn CN115309553A (en) 2022-08-05 2022-08-05 Resource occupation calculation method, calculation device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115309553A (en)

Similar Documents

Publication Publication Date Title
EP3660629B1 (en) Data processing apparatus and method
CN107729935B (en) The recognition methods of similar pictures and device, server, storage medium
US10887199B2 (en) Performance adjustment method, apparatus for performance adjustment, and non-transitory computer-readable storage medium for storing program
CN112650790B (en) Target point cloud plane determining method and device, electronic equipment and storage medium
US11334758B2 (en) Method and apparatus of data processing using multiple types of non-linear combination processing
CN111984400A (en) Memory allocation method and device of neural network
CN111176836B (en) Cloud rendering resource scheduling method and device
CN111967608A (en) Data processing method, device, equipment and storage medium
CN110895706A (en) Method and device for acquiring target cluster number and computer system
CN115309553A (en) Resource occupation calculation method, calculation device, equipment and storage medium
CN115373826B (en) Task scheduling method and device based on cloud computing
CN111221827A (en) Database table connection method and device based on graphic processor, computer equipment and storage medium
CN116451174A (en) Task execution device, method, electronic device, and storage medium
CN111190910A (en) Quota resource processing method and device, electronic equipment and readable storage medium
CN110636522A (en) Method and device for determining coverage quality of communication network
CN114201729A (en) Method, device and equipment for selecting matrix operation mode and storage medium
CN115578583B (en) Image processing method, device, electronic equipment and storage medium
CN112131468A (en) Data processing method and device in recommendation system
CN114841010B (en) Equivalent conductance matrix storage quantization method, device, equipment and readable storage medium
CN105468603A (en) Data selection method and apparatus
CN115292662B (en) Convolution acceleration operation method and device, electronic equipment and storage medium
CN117785487B (en) Method, device, equipment and medium for scheduling computing power resources
CN112905351B (en) GPU and CPU load scheduling method, device, equipment and medium
CN117785486B (en) Environment resource allocation method, device, equipment and medium
CN114579450A (en) Transaction performance testing method and device, storage medium and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right

Effective date of registration: 20230208

Address after: 518055 1501, Building 1, Chongwen Park, Nanshan Zhiyuan, No. 3370, Liuxian Avenue, Fuguang Community, Taoyuan Street, Nanshan District, Shenzhen, Guangdong Province

Applicant after: Shenzhen Grey Shark Technology Co.,Ltd.

Address before: 210022 Room 601, block a, Chuangzhi building, 17 Xinghuo Road, Jiangbei new district, Nanjing City, Jiangsu Province

Applicant before: Nanjing Thunder Shark Information Technology Co.,Ltd.

TA01 Transfer of patent application right
WW01 Invention patent application withdrawn after publication

Application publication date: 20221108

WW01 Invention patent application withdrawn after publication