Memory bandwidth measurement method and device, electronic equipment and storage medium

By obtaining the kernel function handle at the driver layer, switching to serial execution mode, refreshing the cache, and using a hardware counter, the problem of inaccurate memory bandwidth measurement in existing technologies is solved, enabling accurate calculation and performance optimization of memory bandwidth.

CN118964136APending Publication Date: 2024-11-15SHANGHAI BIREN TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411117467.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-14
Publication Date
2024-11-15

AI Technical Summary

Technical Problem

In existing technologies, the method of inserting measurement time slices cannot accurately measure the execution time and memory bandwidth of kernel functions on heterogeneous computing devices, resulting in the inability to accurately measure the efficiency and performance of memory systems.

Method used

The kernel function handle is obtained using a hook function based on the driver layer, the execution mode is switched to serial execution mode, the L2 cache is refreshed, the hardware performance counter is enabled, a performance dump data packet is inserted, the amount of data read and written and the execution time are obtained, and the memory bandwidth is calculated based on these data.

Benefits of technology

It enables accurate measurement of kernel function memory bandwidth, helping developers optimize memory access patterns and algorithms, and improve computing performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118964136A_ABST
    Figure CN118964136A_ABST
Patent Text Reader

Abstract

The invention provides a memory bandwidth measurement method and device, electronic equipment and a storage medium, and the method comprises the steps: obtaining a handle of a current kernel function based on a hook function of a driving layer; based on the handle of the current kernel function, obtaining read-write data volume and execution duration in the execution process; and determining the memory bandwidth of the current kernel function based on the read-write data volume and the execution duration. According to the memory bandwidth measurement method and device, the electronic equipment and the storage medium provided by the invention, the read-write data volume and the execution duration in the execution process can be accurately obtained based on the handle of the current kernel function, so that the memory bandwidth of the current kernel function can be accurately determined based on the read-write data volume and the execution duration; furthermore, performance analysis can be accurately carried out subsequently based on the measured memory bandwidth, and performance optimization is carried out based on an analysis result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of chip technology, and in particular to a memory bandwidth measurement method, device, electronic equipment and storage medium. Background Art

[0002] The bandwidth utilization of High Bandwidth Memory (HBM) refers to the ratio between the actual bandwidth used by the HBM memory system and the theoretical maximum bandwidth in a heterogeneous computing environment, especially when using a graphics processing unit (GPU) for high-performance computing. Bandwidth utilization reflects the efficiency and performance of the HBM memory system when processing data.

[0003] The kernel memory bandwidth is related to the execution time of the kernel and the amount of data read and written. Currently, the kernel execution time is usually measured by inserting a measurement time slice. The specific steps are: first, use the central processing unit (CPU) timestamp of the current program to record the start time of the kernel function, and then record the total time when the kernel function is executed and synchronized to the CPU end, so as to measure the instruction execution time of the kernel function on the GPU.

[0004] Since this method uses the time information of the host side, it is not the real kernel function instruction execution cycle on the heterogeneous computing device. The measured result is often larger than the real result, so it cannot accurately measure the execution time of the kernel function on the heterogeneous computing device. In addition, the hardware cannot count the amount of read and write data in the current time window, and thus cannot accurately obtain the memory bandwidth. Summary of the invention

[0005] The present invention provides a memory bandwidth measurement method, device, electronic device and storage medium to solve the defects existing in the related art.

[0006] The present invention provides a memory bandwidth measurement method, comprising the following steps: Based on the hook function of the driver layer, get the handle of the current kernel function; Based on the handle of the current kernel function, the amount of read and write data and the execution time during the execution process are obtained; Based on the read and write data volume and the execution time, a memory bandwidth of the current kernel function is determined.

[0007] According to a memory bandwidth measurement method provided by the present invention, the amount of read and write data and the execution time during the execution process are obtained based on the handle of the current kernel function, and the method also includes: In the driver layer, the current kernel function is executed after converting the current kernel function from a parallel execution mode to a serial execution mode.

[0008] According to a memory bandwidth measurement method provided by the present invention, before executing the current kernel function, the method further includes: refreshing the secondary cache.

[0009] According to a memory bandwidth measurement method provided by the present invention, the refreshing of the secondary cache further includes: starting a hardware performance counter, the hardware performance counter being used to calculate the amount of read and write data; The executing the current kernel function further includes: after the execution of the current kernel function is completed, closing the hardware performance counter.

[0010] According to a memory bandwidth measurement method provided by the present invention, before starting the hardware performance counter, the method further includes: inserting a first performance dump data packet when the computing unit is started; The method of closing the hardware performance counter further includes: inserting a second performance dump data packet at the end of the computing unit.

[0011] According to a memory bandwidth measurement method provided by the present invention, the memory bandwidth of the current kernel function is determined, and then the method further includes: Based on the first performance dump data packet and the second performance dump data packet, the execution order and / or data access mode of the current kernel function is adjusted.

[0012] According to a memory bandwidth measurement method provided by the present invention, the execution duration is determined based on the number of hardware execution cycles of the current kernel function.

[0013] The present invention also provides a memory bandwidth measurement device, comprising the following modules: A first acquisition unit is used to acquire a handle of a current kernel function based on a hook function of a driver layer; A second acquisition unit, used to acquire the amount of read and write data and the execution time during the execution process based on the handle of the current kernel function; A bandwidth determination unit is used to determine the memory bandwidth of the current kernel function based on the read and write data volume and the execution time.

[0014] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any of the memory bandwidth measurement methods described above is implemented.

[0015] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the memory bandwidth measurement method described in any one of the above methods is implemented.

[0016] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements any of the above-mentioned memory bandwidth measurement methods.

[0017] The memory bandwidth measurement method, device, electronic device and storage medium provided by the present invention can accurately obtain the amount of read and write data and the execution time during the execution process based on the handle of the current kernel function, and then can accurately determine the memory bandwidth of the current kernel function based on the amount of read and write data and the execution time. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the technical solutions in the present invention or related technologies, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0019] Figure 1 It is a flow chart of the memory bandwidth measurement method provided by the present invention.

[0020] Figure 2 It is a principle roadmap of the memory bandwidth measurement technology provided by the present invention.

[0021] Figure 3 It is a flowchart of another memory bandwidth measurement method provided by the present invention.

[0022] Figure 4 It is a structural schematic diagram of the memory bandwidth measurement device provided by the present invention.

[0023] Figure 5 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0024] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. 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.

[0025] Kernel functions typically include GPU kernel functions, which are often used to process large-scale data sets or perform complex mathematical operations. GPU kernel functions are key components in heterogeneous computing. They allow developers to transfer compute-intensive tasks from the CPU to the GPU to accelerate processing. GPU kernel functions have the basic characteristics of parallelism, high performance, data locality, and hardware optimization. GPU kernel functions typically contain a large number of threads that execute in parallel, which can process different parts of the data at the same time, significantly improving computational efficiency. In order to maximize performance, GPU kernel functions typically optimize data access patterns to reduce memory access latency and improve memory bandwidth utilization. The design of GPU kernel functions needs to take into account the architectural characteristics of the target GPU hardware, such as the number of stream processors, register file size, memory hierarchy, etc.

[0026] In terms of kernel performance evaluation, bandwidth utilization involves the influence of two important factors: HBM memory reading and writing and instruction execution. High bandwidth utilization usually means high data transmission efficiency and the ability to complete data-intensive tasks faster. If the bandwidth utilization is low, it may indicate a performance bottleneck and the need to further optimize the memory access pattern or algorithm. For specific computing tasks, by improving HBM bandwidth utilization, data transmission latency can be reduced, thereby improving overall computing performance. This may involve optimization at the algorithm level, such as data reuse, memory access alignment, etc. In short, HBM bandwidth utilization is an important performance indicator that helps developers evaluate and optimize the performance of the GPU memory system, ensuring that data transmission efficiency is maximized, thereby improving overall computing performance. Therefore, accurately measuring the memory bandwidth of kernel functions plays an extremely important role in high-performance computing tuning. Kernel memory bandwidth is related to the execution time of the kernel function and the amount of data read and written.

[0027] At present, the execution time of kernel functions is mostly measured by inserting measurement time slices. The specific steps are: first use the CPU timestamp of the current program to record the start time of the kernel function, and then record the total time when the kernel function is executed and synchronized to the CPU side, so as to measure the instruction execution time of the kernel function on the GPU. Since this method uses the time information on the host side, it is not the real instruction execution cycle of the kernel function on the heterogeneous computing device. The measured result is often larger than the actual result, so it cannot accurately measure the execution time of the kernel function on the heterogeneous computing device. On the other hand, the hardware fails to count the amount of read and write data in the current time window, which makes it difficult for developers to accurately obtain the read and write status of the kernel function, and thus cannot accurately measure the memory bandwidth.

[0028] Figure 1 : is a flow chart of the memory bandwidth measurement method provided by the present invention, such as Figure 1As shown, the method includes step 110 , step 120 and step 130 .

[0029] Step 110: Based on the hook function of the driver layer, obtain the handle of the current kernel function.

[0030] Here, the current kernel function can be understood as a function executed in parallel on the chip, that is, a kernel function that needs to be measured for memory bandwidth. The chip can be an artificial intelligence chip, which can include a graphics processing unit (GPU), a general-purpose graphics processing unit (GPGPU), a tensor processing unit (TPU), a neural processing unit (NPU), etc., and the chip memory can include HBM.

[0031] The handle of the current kernel function refers to a reference or identifier to the current kernel function being executed. The handle of the current kernel function is used to manage, monitor or debug the execution of the current kernel function.

[0032] In addition, the hook function is a mechanism to execute custom code when a specific event occurs. The driver layer can intercept the execution event of the current kernel function by setting the hook function. When the driver layer's hook function captures the execution event of the kernel function, it can provide the handle of the current kernel function to the upper layer application.

[0033] Step 120: Based on the handle of the current kernel function, the amount of read and write data and the execution time during the execution process are obtained.

[0034] Specifically, when executing the current kernel function, the current kernel function will read and write data in the chip memory. The amount of read and write data refers to the amount of data read from the chip memory and the amount of data written to the chip memory during the execution of the current kernel function. The execution time refers to the time required for the current kernel function to run on the chip.

[0035] Since the handle of the current kernel function is used to manage, monitor or debug the execution of the current kernel function, the amount of read and write data and the execution time during the execution of the current kernel function can be monitored and obtained based on the handle of the current kernel function.

[0036] Step 130: Determine the memory bandwidth of the current kernel function based on the amount of read and write data and the execution time.

[0037] Specifically, the amount of read and write data and the execution time can be obtained through the registers in the corresponding hardware performance counter. After the registers are sampled, the amount of read and write data in the HBM can be calculated by a specific mathematical formula to obtain the register sampling value.

[0038] Optionally, the memory bandwidth of the current kernel function may be the HBM read / write bandwidth of the current kernel function. After obtaining the read / write data volume and the execution time, the HBM read / write bandwidth of the current kernel function may be determined based on the following formula:

[0039] in, Indicates the HBM read and write bandwidth of the current kernel function. Indicates the amount of read and write data. Indicates execution time.

[0040] The memory bandwidth measurement method provided by the embodiment of the present invention can accurately obtain the amount of read and write data and the execution time during the execution process based on the handle of the current kernel function, and then can accurately determine the memory bandwidth of the current kernel function based on the amount of read and write data and the execution time.

[0041] Figure 2 This is the principle roadmap of the memory bandwidth measurement technology provided by the present invention, such as Figure 2 As shown in the figure, the kernel function is started, a hook function is established in the driver layer to intercept and obtain the handle of the current kernel function execution, and after inserting the computing unit start PERF Dump package, the hardware performance counter (such as HBM PERF Counter) is turned on and the current kernel function is executed. After the execution is completed, the hardware performance counter is turned off and the computing unit end PERF Dump package is inserted.

[0042] Based on the above embodiment, based on the handle of the current kernel function, the amount of read and write data and the execution time during the execution process are obtained, which also includes: In the driver layer, after converting the current kernel function from the parallel execution mode to the serial execution mode, the current kernel function is executed.

[0043] Specifically, in the driver layer, after converting the current kernel function from parallel execution mode to serial execution mode, it can be ensured that only one kernel function accesses the chip memory at a time, thereby avoiding the problem of errors in the amount of read and write data obtained due to multiple kernel functions accessing the chip memory at the same time.

[0044] Optionally, a mutex lock can be used to enable multiple kernel functions to sequentially access the chip memory. For example, the kernel functions that need to sequentially access the chip memory are wrapped between the locking and unlocking operations of the mutex lock, thereby ensuring that only one kernel function accesses the chip memory at a time.

[0045] Based on any of the above embodiments, executing the current kernel function also includes: refreshing the secondary cache.

[0046] Specifically, in some cases, part of the data accessed by the current kernel function may exist in the L2 cache. If the current kernel function accesses data from the L2 cache, it will affect the calculation of the amount of data read and written from the chip memory (such as HBM). In this regard, the embodiment of the present invention refreshes the L2 cache before executing the current kernel function, thereby avoiding the calculation of the amount of data read and written to the chip memory by the data stored in the L2 cache, ensuring the accuracy of the amount of data read and written, and further ensuring the measurement accuracy of the final memory bandwidth.

[0047] Based on any of the above embodiments, refreshing the secondary cache further includes: enabling a hardware performance counter, the hardware performance counter being used to calculate the amount of read and write data; The current kernel function is executed, and then the method further includes: after the current kernel function is executed, closing the hardware performance counter.

[0048] Specifically, the hardware performance counter is used to calculate the amount of read and write data. Turning on the hardware performance counter means starting to count the amount of read and write data. After turning on the hardware performance counter, the current kernel function is executed, and after the current kernel function is executed, the hardware performance counter is turned off to end counting the amount of read and write data.

[0049] Based on any of the above embodiments, the hardware performance counter is enabled, and the method also includes: inserting a first performance dump data packet when the computing unit is started; Turning off the hardware performance counters, and then further comprising: inserting a second performance dump data packet at the end of the computing unit.

[0050] Specifically, inserting the first performance dump data packet when the computing unit is started means inserting the first performance dump data packet (start dump packet) into the code before executing the current kernel function. The first performance dump data packet may be used to record the chip memory performance indicators before the current kernel function is executed.

[0051] Next, the hardware performance counter is turned on to start counting the amount of read and write data. After the current kernel function is executed, the hardware performance counter is turned off to stop the hardware performance counter's statistical work. After the hardware performance counter is turned off, the second performance dump data packet (end dump packet) is inserted to capture the chip memory performance indicators at the end of the current kernel function execution.

[0052] Next, the chip memory may be subjected to performance analysis based on the difference between the performance indicators in the second performance dump data packet and the performance indicators in the first performance dump data packet. For example, the memory access patterns in the first performance dump data packet and the second performance dump data packet may be compared to check the changes in the memory read and write patterns, such as the frequency and sequence of read and write operations, and whether there are irregular memory access patterns. If the memory access pattern has changed, optimization may be required to improve efficiency.

[0053] For another example, the memory bandwidth utilization in the first performance dump data packet and the second performance dump data packet may be checked. If the second performance dump data packet shows a higher memory bandwidth utilization, the data transmission method may need to be further optimized to maximize the memory bandwidth utilization and reduce bottlenecks.

[0054] Based on any of the above embodiments, the memory bandwidth of the current kernel function is determined, and then the following steps are further included: Based on the first performance dump data packet and the second performance dump data packet, the execution order and / or data access mode of the current kernel function is adjusted.

[0055] Specifically, the execution order of the current kernel function is evaluated according to the performance indicators in the first performance dump data packet and the second performance dump data packet. If the execution order of certain operations leads to performance degradation, it is possible to consider rearranging the execution order of these operations. For example, priority is given to executing computationally intensive operations, or the execution order is optimized through parallelization or pipelining to reduce idle cycles and improve computing resource utilization.

[0056] According to the performance indicators in the first performance dump data packet and the second performance dump data packet, the data access mode is adjusted, such as accessing data from a shared memory, thereby reducing unnecessary data copy operations.

[0057] Based on any of the above embodiments, the execution duration is determined based on the number of hardware execution cycles of the current kernel function.

[0058] Specifically, the number of hardware execution cycles refers to the number of basic unit operations required when the current kernel function is executed on hardware (such as a CPU or a GPU). The number of hardware execution cycles can be converted into execution duration based on the frequency of the hardware of the current kernel function.

[0059] Figure 3 is a flow chart of another memory bandwidth measurement method provided by the present invention, such as Figure 3 As shown, the method includes: Start the kernel function (Kernel Launch), and in the driver layer, convert all kernel functions from parallel execution mode to serial execution mode (serial kernel).

[0060] Next, a hook function is established at the driver layer to intercept and obtain the handle of the current kernel function execution (capture the Kernel handle). Confirm whether the L2 cache is cleared. If so, flush the L2 cache (Flush L2 Cache) and insert the computing unit start dump package; if not, insert the computing unit start dump package. Among them, after establishing the hook function, a series of instructions can be sent to the hardware. The purpose of flushing the L2 cache is to measure the accuracy of the results and avoid cache hits. The access to high-speed memory does not go through HBM.

[0061] After inserting the computing unit start dump package, turn on the HBM hardware performance counter (PERF Counter), and execute the current kernel function (Kernel execution). After the execution is completed, turn off the HBM hardware performance counter (PERF Counter) and insert the computing unit end dump package. Calculate the active hardware instruction cycle, obtain the computing unit operating frequency, and convert the hardware instruction cycle into execution time based on the computing unit operating frequency. At the same time, determine the amount of HBM register read and write data based on the HBM hardware performance counter, and calculate the memory bandwidth of the current kernel function based on the execution time and the amount of read and write data. Among them, the active hardware instruction cycle refers to the instruction cycle sent to the hardware by the kernel function. The computing unit refers to the GPU device, NPU device, etc. where the kernel function runs.

[0062] Finally, confirm whether to dump the next kernel. If so, capture the handle of the next kernel, so that performance analysis can be performed on a series of kernels in the large model to obtain analysis results.

[0063] The embodiment of the present invention captures and analyzes the execution details of the kernel function on the chip, including the read and write bandwidth and instruction cycle, through the start dump package and the end dump package, so that the developer can obtain accurate performance data. In addition, the developer can understand how the kernel function utilizes the memory bandwidth of the chip, which can help the developer identify and optimize the bottleneck of resource utilization. For example, by adjusting the execution order or data access mode of the kernel function, the memory bandwidth of the chip can be more effectively utilized, thereby improving the overall performance. Based on the measured performance data, the developer can perform performance optimization in a targeted manner. For example, by reducing unnecessary data transmission or optimizing the memory access mode, the execution efficiency of the kernel function can be significantly improved. After implementing the optimization measures, the developer can verify the effect of the optimization measures by measuring the memory bandwidth of the kernel function again.

[0064] The memory bandwidth measurement device provided by the present invention is described below. The memory bandwidth measurement device described below and the memory bandwidth measurement method described above can be referred to each other.

[0065] Based on any of the above embodiments, Figure 4 is a schematic diagram of the structure of the memory bandwidth measurement device provided by the present invention, such as Figure 4 As shown, the device comprises: A first acquisition unit 410 is used to acquire a handle of a current kernel function based on a hook function of a driver layer; A second acquisition unit 420 is used to acquire the amount of read and written data and the execution time during the execution process based on the handle of the current kernel function; The bandwidth determination unit 430 is used to determine the memory bandwidth of the current kernel function based on the amount of read and write data and the execution time.

[0066] Based on any of the above embodiments, based on the handle of the current kernel function, the amount of read and write data and the execution time during the execution process are obtained, and the above also includes: In the driver layer, after converting the current kernel function from the parallel execution mode to the serial execution mode, the current kernel function is executed.

[0067] Based on any of the above embodiments, executing the current kernel function also includes: refreshing the secondary cache.

[0068] Based on any of the above embodiments, refreshing the secondary cache further includes: enabling a hardware performance counter, the hardware performance counter being used to calculate the amount of read and write data; The current kernel function is executed, and then the method further includes: after the current kernel function is executed, closing the hardware performance counter.

[0069] Based on any of the above embodiments, the hardware performance counter is enabled, and the method also includes: inserting a first performance dump data packet when the computing unit is started; Turning off the hardware performance counters, and then further comprising: inserting a second performance dump data packet at the end of the computing unit.

[0070] Based on any of the above embodiments, the memory bandwidth of the current kernel function is determined, and then the following steps are further included: Based on the first performance dump data packet and the second performance dump data packet, the execution order and / or data access mode of the current kernel function is adjusted.

[0071] Based on any of the above embodiments, the execution duration is determined based on the number of hardware execution cycles of the current kernel function.

[0072] Figure 5 is a schematic diagram of the structure of the electronic device provided by the present invention, such as Figure 5As shown, the electronic device may include: a processor 510, a communication interface 520, a memory 530 and a communication bus 540, wherein the processor 510, the communication interface 520 and the memory 530 communicate with each other through the communication bus 540. The processor 510 may call the logic instructions in the memory 530 to execute the memory bandwidth measurement method, which includes: obtaining the handle of the current kernel function based on the hook function of the driver layer; obtaining the amount of read and write data and the execution time during the execution process based on the handle of the current kernel function; and determining the memory bandwidth of the current kernel function based on the amount of read and write data and the execution time.

[0073] In addition, the logic instructions in the above-mentioned memory 530 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the relevant technology or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0074] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the memory bandwidth measurement method provided by the above methods, the method including: based on the hook function of the driver layer, obtaining the handle of the current kernel function; based on the handle of the current kernel function, obtaining the amount of read and write data and the execution time during the execution process; based on the amount of read and write data and the execution time, determining the memory bandwidth of the current kernel function.

[0075] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, it is implemented to execute the memory bandwidth measurement method provided by the above-mentioned methods, the method comprising: obtaining a handle of the current kernel function based on a hook function of the driver layer; obtaining the amount of read and write data and the execution time during the execution process based on the handle of the current kernel function; and determining the memory bandwidth of the current kernel function based on the amount of read and write data and the execution time.

[0076] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0077] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiment.

[0078] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A memory bandwidth measurement method, characterized in that: include: Based on the hook function of the driver layer, get the handle of the current kernel function; Based on the handle of the current kernel function, the amount of read and write data and the execution time during the execution process are obtained; Based on the read and write data volume and the execution time, a memory bandwidth of the current kernel function is determined.

2. The memory bandwidth measurement method according to claim 1, characterized in that: The method of obtaining the amount of read and write data and the execution time during the execution process based on the handle of the current kernel function also includes: In the driver layer, the current kernel function is executed after converting the current kernel function from a parallel execution mode to a serial execution mode.

3. The memory bandwidth measurement method according to claim 2, characterized in that: The executing of the current kernel function also includes: refreshing the secondary cache.

4. The memory bandwidth measurement method according to claim 3, characterized in that: The refreshing of the secondary cache further includes: starting a hardware performance counter, the hardware performance counter being used to calculate the amount of read and write data; The executing the current kernel function further includes: after the execution of the current kernel function is completed, closing the hardware performance counter.

5. The memory bandwidth measurement method according to claim 4, characterized in that: The step of enabling the hardware performance counter also includes: inserting a first performance dump data packet when the computing unit is started; The method of closing the hardware performance counter further includes: inserting a second performance dump data packet at the end of the computing unit.

6. The memory bandwidth measurement method according to claim 5, characterized in that: The determining of the memory bandwidth of the current kernel function further comprises: Based on the first performance dump data packet and the second performance dump data packet, the execution order and / or data access mode of the current kernel function is adjusted.

7. The memory bandwidth measurement method according to any one of claims 1 to 6, characterized in that: The execution duration is determined based on the number of hardware execution cycles of the current kernel function.

8. A memory bandwidth measurement device, characterized in that: include: A first acquisition unit is used to acquire a handle of a current kernel function based on a hook function of a driver layer; A second acquisition unit, used to acquire the amount of read and write data and the execution time during the execution process based on the handle of the current kernel function; A bandwidth determination unit is used to determine the memory bandwidth of the current kernel function based on the read and write data volume and the execution time.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the memory bandwidth measurement method according to any one of claims 1 to 7 is implemented.

10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the memory bandwidth measurement method according to any one of claims 1 to 7 is implemented.

Citation Information

Cited By

  • System memory peak bandwidth measurement method and electronic equipment

    CN120892273A