User side force quantity calculation method based on CPU platform and program product
Through the BOPs-based method, the computing power of different CPU architectures is uniformly measured, which solves the problem of inability to adapt to the diversity of heterogeneous computing power loads in the existing technology, and realizes the computing power measurement and on-demand use on the user side, avoiding resource waste .
Patent Information
- Application Number
- CN202510083293.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-20
- Publication Date
- 2025-02-25
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing computing power measurement indicators cannot meet the diversity needs of heterogeneous computing power loads, and users find it difficult to reasonably choose configurations when using cloud computing resources, which can easily lead to resource waste and unnecessary overhead.
Using a method based on BOPs (Basic Operations) definition, starting from the user side through the perfstat tool, the computing power value of the process from the beginning to the end is counted, and the 64-bit basic operation BOPs indicator is used for unified measurement.
It realizes a unified measurement of the computing power of different CPU architectures, truly measures the computing power value used from the user side, avoids resource waste and unnecessary overhead, and realizes the use of computing power on demand.
Smart Images

Figure SMS_11 
Figure QLYQS_1
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a user-side computing power measurement method and program product based on a CPU platform. Background Art
[0002] The development of cloud computing has enabled more and more computing tasks to be completed on the cloud, and people tend to use "computing power" to evaluate the overall computing power of cloud computing centers. "Computing power" literally means computing power, which is borrowed from the power of electricity and transportation capacity. The computer academic community has a general consensus on the concept of "computing power", which means the computing performance of a certain device or system, or "computing power" is a colloquial expression of computing performance, similar to "computer" being a colloquial expression of computer. People generally use computing speed as an indicator to characterize computing performance, including millions of instructions per second (MIPS), floating-point operations per second (FLOPS), fixed-point operations per second (OPS), etc., to indicate the performance of fixed-point, half-precision / single-precision / double-precision floating-point, and 8-bit integer operations commonly used in artificial intelligence.
[0003] For computing power providers, the indicator system for heterogeneous computing power is different. For example, the XPU indicator is OPS (8 / 16-bit integer operations), the GPU indicator is FLOPS (16 / 32-bit floating-point operations), and the CPU indicator is FLOPS (64-bit floating-point operations). The indicator system based on 64-bit floating-point operation FLOPS is difficult to adapt to the diverse needs of heterogeneous computing power loads. The existing indicator system lacks a unified measurement indicator for heterogeneous computing power.
[0004] For users who use computing power, the traditional method is to rent a cloud server on the public cloud and pay according to the usage time. That is, users choose the cloud server with the required specifications (CPU, memory, etc.) on the cloud platform, and choose the billing method (annual package, monthly package, pay-as-you-go) to pay for use. The annual package billing method is a one-time deduction of the monthly fee, which is a prepaid method. The pay-as-you-go method is a post-payment method. One hour of fees is deducted from the user's balance every hour. The billing will stop when the cloud server is released. If the cloud server is not released, it will remain in the billing state. The billing items include computing resources (vcpu and memory), public network IP and bandwidth, system disk, data disk, and charged images. The existing billing method has certain requirements for the user's professional background in order to use computing power resources reasonably. Due to the different professional backgrounds of users, some users do not know whether their choices are reasonable, and may purchase unnecessary high-configuration computing power. Since the price of high-configuration computing power is higher than that of low-configuration computing power, there will be a waste of resources, which means unnecessary expenses for users. Different cloud vendors have different charging standards for cloud servers with the same configuration, which results in a conflict between user experience and user payment.
[0005] Therefore, how to uniformly measure the computing power of different CPU architectures is an urgent problem that needs to be solved. Summary of the invention
[0006] The user-side computing power measurement method based on the CPU platform in the present invention is based on the definition of BOPs (Basic Operations) to achieve a unified measurement of the computing power of different CPU architectures, and a single measurement centered on the user, that is, the user pays according to the computing power used, rather than by duration and cloud server configuration. This method is based on the 64-bit basic operation BOPs indicator, uses the perfstat tool, starts from the user side, and uses one or more processes as dimensions to count the computing power consumed by the process from start to end.
[0007] The present invention provides a method for measuring user-side computing power based on a CPU platform, comprising the following steps:
[0008] S1: Get the total BOPs value of the CPU platform within a specified time, where the total BOPs value refers to the basic operands of calculation operations, comparison operations, and address operations corresponding to CPU integer and floating-point calculations;
[0009] S2: Normalize the total BOPs value to a preset number of digits as the computing power of the corresponding CPU platform within a specified time.
[0010] Furthermore, the total BOPs value is obtained by setting a performance counter in a non-invasive manner, and the performance counter is a hardware register.
[0011] Furthermore, the method of obtaining the total BOPs value through the performance counter is as follows:
[0012] The operating system kernel issues instructions to the PMU, allowing the PUM to initialize a hardware register as a performance counter to accumulate the basic operands corresponding to the total BOPs value;
[0013] When the performance counter overflows, the PUM triggers a PMI interrupt;
[0014] The operating system kernel saves the count value of the performance counter in the PMI interrupt processing function and stores it in the Ring Buffer used to communicate with the user space;
[0015] Read data from the Ring Buffer to obtain the total BOPs value.
[0016] Furthermore, the preset number of bits is 64 bits.
[0017] Furthermore, the total BOPs value within a specified time is calculated by the following formula:
[0018]
[0019] Among them, BOP represents the total BOPs value of the current CPU platform within a specified time;
[0020] N represents the total number of seconds of the specified time;
[0021] Indicates the total number of instruction operations in the i-th second of the specified time;
[0022] The branch instruction operand representing the i-th second of the specified time;
[0023] The Load instruction operand representing the i-th second of the specified time;
[0024] Indicates the number of Store instructions at the i-th second of the specified time.
[0025] The present invention also provides a computer program product, comprising a computer program, which implements the above method when executed by a processor.
[0026] Beneficial effects: Compared with the existing technology, the present invention has the following advantages: First, the traditional computing power measurement indicators cannot be applied to heterogeneous computing power. The present invention uses BOPs and normalizes to 64-bit operations, which is suitable for the unified measurement of heterogeneous computing power. Second, the present invention provides a statistical method for heterogeneous computing power values. That is, by running the tool, all computing power values consumed during the life cycle of the process can be monitored. Starting from the user side, the computing power value actually used by the user can be measured. There is no need to rent computing power, and there will be no problem of waste of resources, so that computing power can be used on demand. DETAILED DESCRIPTION
[0027] In order to make the purpose, features and advantages of the present invention more obvious and easy to understand, the technical solutions in the embodiments of the present invention are described clearly and completely below. Obviously, the embodiments described below are only part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0028] A method for measuring computing power on a user side based on a CPU platform comprises the following steps:
[0029] S1: Get the total BOPs value of the CPU platform within a specified time, where the total BOPs value refers to the basic operands of calculation operations, comparison operations, and address operations corresponding to CPU integer and floating-point calculations;
[0030] For CPU platforms, instructions can be divided into five categories: Load instructions, Store instructions, branch instructions, integer instructions, and floating-point instructions. According to the definition and calculation method of the total BOPs value, the number of all floating-point and integer operation instructions can be obtained by subtracting the number of branch instructions, Load instructions, and Store instructions from the total number of instructions, thereby obtaining the number of basic operations (integer, floating-point) corresponding to the total BOPs value.
[0031] There are currently two ways to obtain the total BOPs value. One is the white-box calculation method, which requires analyzing and understanding the program logic and inserting calculation code at the corresponding location. For complex applications, a large amount of software stack and execution process analysis is required, and the calculation cost is huge. The other is the black-box calculation method, which uses performance counters to obtain it in a non-invasive way. The black-box calculation method is more feasible and practical.
[0032] In this embodiment, the total BOPs value is obtained by setting a performance counter (PMC: Performance Monitoring Counter) in a non-invasive manner. The performance counter is a hardware register. The performance counter can be used on most modern CPUs and will not slow down the kernel or application.
[0033] In a further embodiment, the total BOPs value is obtained by using the performance counter as follows:
[0034] The operating system kernel issues instructions to the PMU, asking the PUM (Performance Monitoring Unit) to initialize a hardware register as a performance counter and accumulate the basic operands corresponding to the total BOPs value;
[0035] When the performance counter overflows, the PUM triggers a PMI (Performance Monitoring Interrupt) interrupt;
[0036] The operating system kernel saves the count value of the performance counter in the PMI interrupt processing function and stores it in the Ring Buffer used to communicate with the user space;
[0037] Read data from the Ring Buffer to obtain the total BOPs value;
[0038] For example, in Linux, the above process can be implemented by calling the performance profiling tool Perf in the Linux kernel source tree to obtain the total BOPs value. Perf has a non-invasive hardware counter function, which is implemented by the performance counter kernel subsystem. Perf can perform hot spot searches at the function level and instruction level. Perf falls into the kernel through the system call sys_perf_event_open, and the kernel initializes a performance counter on the PMU based on the information provided by Perf. The performance counter automatically accumulates as the specified hardware event occurs. When the performance counter overflows, the PMU triggers a PMI interrupt. The kernel saves the count value of the performance counter, the instruction address when the interrupt is triggered, the current timestamp, and the PID, TID, comm and other information of the current process in the PMI interrupt processing function. This information is collectively referred to as a sample. The kernel will put the collected samples into the Ring Buffer used to communicate with the user space. The Perf analysis program in the user space uses the mmap mechanism to read the samples from the ring buffer and parse them to collect and record performance data. The perf stat command is a very useful command in the Perf tool suite. It is used to count and analyze the performance data of the program when it is running. There is no need to deeply analyze the specific code execution path or function call. The perf stat command will summarize and display a series of performance statistics after the program is executed. The perf stat command can count the number of operations corresponding to various events.
[0039] The following describes how to use Perf to obtain the total BOPs value:
[0040] 1. Check the official user manual corresponding to the CPU architecture and find the performance monitoring event name. Find the event name corresponding to the total instruction, and record it in lowercase as: ins_total_name. For example, by looking up the official Intel user manual, for the Skylake architecture, the event name corresponding to the total instruction is INST_RETIRED.ANY_P (lowercase form: inst_retired.any_p), so the value of ins_total_name for the Skylake architecture is: inst_retired.any_p.
[0041] 2. Refer to step 1 to find the event name corresponding to the branch instruction, which is written in lowercase as ins_branch_name. For example, by looking up the official Intel user manual, for the Skylake architecture, the event name corresponding to the branch instruction is BR_INST_RETIRED.ALL_BRANCHES (lowercase form: br_inst_retired.all_branches), so the value of ins_branch_name for the Skylake architecture is: br_inst_retired.all_branches.
[0042] 3. Refer to step 1 to find the event name corresponding to the Load instruction, which is written in lowercase as ins_load_name. For example, by looking up the official Intel user manual, for the Skylake architecture, the event name corresponding to the Load instruction is MEM_INST_RETIRED.ALL_LOADS (lowercase form: mem_inst_retired.all_loads), so the value of ins_load_name for the Skylake architecture is: mem_inst_retired.all_loads.
[0043] 4. Refer to step 1 to find the event name corresponding to the Store instruction, which is written in lowercase as ins_store_name. For example, by looking up the official Intel user manual, for the Skylake architecture, the event name corresponding to the Store instruction is MEM_INST_RETIRED.ALL_STORES (lowercase form: mem_inst_retired.all_stores), so the value of ins_store_name for the Skylake architecture is: mem_inst_retired.all_stores.
[0044] 5. Log in to the CPU platform (that is, the Linux environment of the physical machine) and install the perf tool.
[0045] 6. After Perf is successfully installed, execute the perf stat command:
[0046] "perf stat -e ins_total_name -e ins_branch_name -e ins_load_name -eins_store_name -I 1000 ".
[0047] Among them, ins_total_name refers to the event name corresponding to the total instruction, ins_branch_name refers to the event name corresponding to the branch instruction, ins_load_name refers to the event name corresponding to the Load instruction, and ins_store_name refers to the event name corresponding to the Store instruction.
[0048] For example, on a Skylake architecture CPU platform, you can execute the command: "perf stat -e inst_retired.any_p -e br_inst_retired.all_branches -e mem_inst_retired.all_loads -e mem_inst_retired.all_stores -I 1000".
[0049] 7. From the command execution results of step 6, you can get the total number of instructions per second, branch instructions per second, Load instructions per second, and Store instructions per second of the current CPU platform. Therefore, the total BOPs value of the current CPU platform within the specified time can be calculated by the following formula:
[0050]
[0051] Among them, BOP represents the total BOPs value of the current CPU platform within a specified time;
[0052] N represents the total number of seconds of the specified time;
[0053] Indicates the total number of instruction operations in the i-th second of the specified time;
[0054] The branch instruction operand representing the i-th second of the specified time;
[0055] The Load instruction operand representing the i-th second of the specified time;
[0056] Represents the Store instruction operand at the i-th second of the specified time;
[0057] S2: Normalize the total BOPs value to a preset number of digits as the computing power of the corresponding CPU platform within a specified time.
[0058] In this embodiment, the preset number of bits is 64 bits;
[0059] Example of the process of normalizing the total BOPs value: each basic operation of a preset number of bits is counted as 1, and basic operations of other bits are counted as the number of bits / preset number of bits. For example, the preset number of bits in this embodiment is 64 bits, so a 64-bit basic operation is counted as 1, and a 32-bit basic operation is counted as 0.5. Therefore, the method in the present invention is applicable to the unified measurement of heterogeneous computing power. The specific calculation method is shown in Table 1.
[0060] Table 1 BOPs normalization calculation table
[0061]
[0062] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for measuring user-side computing power based on a CPU platform, characterized in that: The following steps are involved: S1: Get the total BOPs value of the CPU platform within a specified time, where the total BOPs value refers to the basic operands of calculation operations, comparison operations, and address operations corresponding to CPU integer and floating-point calculations; S2: Normalize the total BOPs value to a preset number of digits as the computing power of the corresponding CPU platform within a specified time.
2. According to a method for measuring user-side computing power based on a CPU platform according to claim 1, it is characterized in that: The total BOPs value is obtained by setting a performance counter in a non-invasive manner, and the performance counter is a hardware register.
3. According to a method for measuring user-side computing power based on a CPU platform as described in claim 2, it is characterized in that: The way to obtain the total BOPs value through performance counters is: The operating system kernel issues instructions to the PMU, allowing the PUM to initialize a hardware register as a performance counter to accumulate the basic operands corresponding to the total BOPs value; When the performance counter overflows, the PUM triggers a PMI interrupt; The operating system kernel saves the count value of the performance counter in the PMI interrupt processing function and stores it in the Ring Buffer used to communicate with the user space; Read data from the Ring Buffer to obtain the total BOPs value.
4. According to a method for measuring user-side computing power based on a CPU platform as described in claim 1, it is characterized in that: The default bit number is 64 bits.
5. According to a method for measuring user-side computing power based on a CPU platform as described in claim 1, it is characterized in that: The total BOPs value within a specified time is calculated by the following formula: Among them, BOP represents the total BOPs value of the current CPU platform within a specified time; N represents the total number of seconds of the specified time; Indicates the total number of instruction operations in the i-th second of the specified time; The branch instruction operand representing the i-th second of the specified time; The Load instruction operand representing the i-th second of the specified time; Indicates the number of Store instructions at the i-th second of the specified time.
6. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Operation system performance analysis method and device
CN102004678A
Method for uniformly measuring computing power resources of equipment
CN118427055A
Extract CPU time facility
US20070271566A1
Cited By
Simulation computing power scheduling method, system and equipment and readable storage medium
CN121705037A