A method, device and storage medium for detecting performance of a heterogeneous accelerator program

By adding target class library files and interface functions to the heterogeneous acceleration program, obtaining clock count values, and calculating runtime, the problems of low accuracy and runtime distortion in existing detection tools are solved, achieving high-precision performance detection and code optimization support.

CN116126669BActive Publication Date: 2026-07-14SHUGUANG ZHISUAN INFORMATION TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SHUGUANG ZHISUAN INFORMATION TECH CO LTD
Filing Date
2023-02-24
Publication Date
2026-07-14

AI Technical Summary

Technical Problem

Existing heterogeneous accelerator performance testing tools have low detection accuracy, and the process interaction between them and the heterogeneous accelerators increases the running time, resulting in distortion of function execution time.

Method used

By adding target class library files to the heterogeneous acceleration program, which contain interface functions for reading the clock count value of the heterogeneous accelerator, the clock count value is obtained and stored to calculate the execution time of the target code segment, including the maximum, average and minimum execution time. Combined with the proportion of thread groups and the data processing task type, the execution time correlation is constructed to determine the exception function and code segment.

Benefits of technology

It improves the precision and accuracy of performance testing for heterogeneous acceleration programs, avoids distortion caused by function execution time consumption, and provides comprehensive performance analysis basis and code optimization support.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116126669B_ABST
    Figure CN116126669B_ABST
Patent Text Reader

Abstract

The application discloses a kind of performance detection methods, device, electronic equipment and storage medium of heterogeneous acceleration procedure, it is related to performance test field, the method comprises: the target class library file is added to the heterogeneous acceleration procedure to be detected;Interface function is associated with the target code segment in heterogeneous acceleration procedure, to make heterogeneous acceleration procedure run to target code segment, current clock count value is obtained by interface function when the target code segment is run and is stored in target class library file;Compiling and running heterogeneous acceleration procedure, to obtain the running time consumption of target code segment by the clock count value stored in target class library file.The technical scheme of the embodiment of the application realizes the running time consumption detection of specific code segment in heterogeneous acceleration procedure, improves the performance detection precision of heterogeneous acceleration procedure, simultaneously, the influence of the running time consumption of heterogeneous acceleration procedure is very small, avoids the distortion phenomenon of function running time consumption, greatly improves the accuracy of the performance result obtained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of performance testing, and more particularly to a method, apparatus, electronic device, and storage medium for performance testing of heterogeneous acceleration programs. Background Technology

[0002] Unlike ordinary applications that use the central processing unit to process data computing tasks, heterogeneous acceleration programs are applications that use heterogeneous accelerators (e.g., accelerated computing cards) to perform large-scale data computing. Their performance directly determines the data processing capabilities of the heterogeneous accelerator.

[0003] In the existing technology, the performance testing of heterogeneous accelerated programs is usually carried out by using existing performance testing tools (such as rocprof) to directly obtain the performance test results. The test results include the execution time of each function in the code file, thereby providing a basis for performance analysis for the testers.

[0004] However, the aforementioned performance testing tools cannot obtain performance testing results at a smaller granularity within each function, resulting in low testing accuracy. Furthermore, excessive process interaction between them and heterogeneous acceleration programs increases the execution time of these programs, leading to distortion of function execution time and significant errors in the performance testing results. Summary of the Invention

[0005] This invention provides a method, apparatus, electronic device, and storage medium for performance testing of heterogeneous acceleration programs, in order to solve the problem of low detection accuracy in performance testing of heterogeneous acceleration programs.

[0006] According to one aspect of the present invention, a method for performance testing of heterogeneous acceleration programs is provided, comprising:

[0007] Add the target library file to the heterogeneous accelerator to be detected; wherein, the target library file includes interface functions for reading the clock count value of the heterogeneous accelerator;

[0008] The interface function is associated with at least one target code segment in the heterogeneous acceleration program so that when the heterogeneous acceleration program runs to the target code segment, it obtains the current clock count value through the interface function and stores the current clock count value in the target class library file.

[0009] Compile and run the heterogeneous acceleration program to obtain the execution time of the target code segment through the clock count value stored in the target class library file.

[0010] The process of compiling and running the heterogeneous acceleration program to obtain the execution time of the target code segment using the clock count value stored in the target library file specifically includes: compiling and running the heterogeneous acceleration program to obtain the execution time of the target code segment in multiple target threads using the clock count value stored in the target library file; wherein, the execution time includes at least one of maximum execution time, average execution time, and minimum execution time. Maximum execution time, average execution time, and minimum execution time reflect the worst-case performance, general performance, and best-case performance of a target code segment running in different threads, respectively, thus providing testers with a comprehensive basis for performance analysis. Furthermore, if the maximum execution time differs significantly from the minimum execution time, or if the maximum execution time differs significantly from the average execution time, it can be inversely determined that the physical thread corresponding to the maximum execution time has performance anomalies, further obtaining the performance test results of the heterogeneous accelerator's physical structure.

[0011] If the percentage of called threads in the current thread group is greater than or equal to a first percentage threshold, then the called threads in the current thread group are designated as target threads; if the percentage of called threads in the current thread group is less than the first percentage threshold, then the called threads in the current thread group are designated as non-target threads. This avoids distortion of runtime when the current thread is handling overly simple data calculation tasks, which could lead to erroneous runtime data that differs significantly from the actual data processing task, thus improving the accuracy of runtime detection for the target code segment.

[0012] Based on data volume, data type, and computation method, different types of data processing tasks are constructed. Based on these different data processing tasks, the heterogeneous acceleration program is compiled and run to obtain the runtime of the target code segment under each data processing task using the clock count value stored in the target class library file. This enables the acquisition of the runtime of the target code segment under different types of data processing tasks, further expanding the performance testing scope of the target code segment. Simultaneously, based on the runtime of the target code segment under different types of data processing tasks, the computational bottleneck of each data processing task can also be identified, providing a data foundation for further improving the computational efficiency of the heterogeneous acceleration program.

[0013] Based on data type and calculation method, different types of data processing tasks are constructed, and the time consumption correlation of each type of data processing task is obtained. The time consumption correlation reflects the proportional relationship between the running time corresponding to different data volumes. Based on different types of data processing tasks, the heterogeneous acceleration program is compiled and run to obtain the running time of the target code segment under different data volumes in each of the data processing tasks through the clock count value stored in the target class library file. If the running time of the target code segment under different data volumes in the target data processing task conforms to the corresponding time consumption correlation, it is determined that the target code segment does not have any abnormal running time. By matching the running time between different data volumes with the corresponding time consumption correlation in different types of data processing tasks according to different data type and calculation method, it is possible not only to detect whether the target code segment has excessively long running time in each data processing task, but also to obtain the specific data volume when the excessively long running time occurs, thus providing necessary data support for code optimization of the target code segment by the testing personnel.

[0014] If the execution time of the target code segment under different data volumes in the target data processing task does not conform to the corresponding time consumption correlation, then the first and second data volumes that do not conform to the time consumption correlation are obtained; it is then determined whether the execution time of the first data volume and the execution time of the second data volume in other types of data processing tasks conform to the corresponding time consumption correlation; if they do not conform to the time consumption correlation, it is determined that the heterogeneous acceleration program has an abnormal execution time for the first data volume or the second data volume; if they conform to the time consumption correlation, it is determined that the abnormal acceleration program has an abnormal execution time for the target data processing task. This further determines whether the abnormal execution time of the target code segment is due to excessively large or small data volumes, or whether it only occurs when processing specific types of data processing tasks, further ensuring the accuracy of the performance testing results of the heterogeneous acceleration program.

[0015] The abnormal functions are identified based on the execution time of each function in the heterogeneous acceleration program, and the code segments within these abnormal functions are set as target code segments. The execution time of the abnormal function accounts for a proportion greater than or equal to a second proportion threshold, or the execution time of the abnormal function is greater than or equal to a first time threshold. After preliminary detection of function execution time using performance testing tools, the execution time of key code segments under abnormal functions with longer execution times is monitored. This approach achieves targeted labeling of target code segments, avoiding the existence of too many target code segments that could reduce the performance testing efficiency of the heterogeneous acceleration program, and also improves the accuracy of execution time detection results.

[0016] According to another aspect of the present invention, a performance testing apparatus for heterogeneous acceleration programs is provided, comprising:

[0017] The file addition execution module is used to add target library files to the heterogeneous acceleration program to be detected; wherein, the target library files include interface functions for reading the clock count values ​​of the heterogeneous accelerator;

[0018] The execution association module is used to associate the interface function with at least one target code segment in the heterogeneous acceleration program, so that when the heterogeneous acceleration program runs to the target code segment, it obtains the current clock count value through the interface function and stores the current clock count value in the target class library file;

[0019] The runtime acquisition module is used to compile and run the heterogeneous acceleration program to acquire the runtime of the target code segment through the clock count value stored in the target class library file.

[0020] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:

[0021] At least one processor; and

[0022] A memory communicatively connected to the at least one processor; wherein,

[0023] The memory stores a computer program that can be executed by the at least one processor, which is then executed by the at least one processor to enable the at least one processor to perform the performance testing method for heterogeneous acceleration programs according to any embodiment of the present invention.

[0024] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the performance testing method of the heterogeneous acceleration program according to any embodiment of the present invention.

[0025] The technical solution of this invention involves adding the target class library file to the heterogeneous acceleration program to be tested and associating the interface function with the target code segment in the heterogeneous acceleration program. The heterogeneous acceleration program is then compiled and run. When the heterogeneous acceleration program reaches the target code segment, it obtains the current clock count value through the interface function and stores it in the target class library file. Then, the execution time of the target code segment is obtained through the clock count value stored in the target class library file. This not only achieves the detection of the execution time of specific code segments in the heterogeneous acceleration program, improving the performance detection accuracy of the heterogeneous acceleration program, but also, compared to the frequent process interactions between traditional performance testing tools and heterogeneous acceleration programs, the heterogeneous acceleration program in this embodiment only needs to perform the clock count value acquisition and storage operation through the interface function, having minimal impact on the execution time of the heterogeneous acceleration program. This avoids distortion of function execution time and greatly improves the accuracy of the obtained performance results.

[0026] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description

[0027] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0028] Figure 1 This is a flowchart of a performance testing method for heterogeneous acceleration programs provided in Embodiment 1 of the present invention;

[0029] Figure 2 This is a flowchart of a performance testing method for a heterogeneous acceleration program according to Embodiment 2 of the present invention;

[0030] Figure 3 This is a flowchart of a performance testing method for a heterogeneous acceleration program provided in Embodiment 3 of the present invention;

[0031] Figure 4 This is a schematic diagram of the structure of a performance testing device for a heterogeneous acceleration program according to Embodiment 4 of the present invention;

[0032] Figure 5 This is a schematic diagram of the structure of an electronic device that implements the performance testing method of the heterogeneous acceleration program according to an embodiment of the present invention. Detailed Implementation

[0033] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0034] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0035] Example 1

[0036] Figure 1 This is a flowchart of a performance testing method for heterogeneous acceleration programs provided in Embodiment 1 of the present invention. This embodiment is applicable to monitoring the running time of heterogeneous acceleration programs on heterogeneous accelerators. This method can be executed by a performance testing device for heterogeneous acceleration programs, which can be implemented in hardware and / or software and configured in an electronic device. Figure 1 As shown, the method includes:

[0037] S101. Add the target class library file to the heterogeneous accelerator program to be detected; wherein, the target class library file includes interface functions for reading the clock count value of the heterogeneous accelerator.

[0038] Because the heterogeneous accelerator driver supports real-time reading of the accelerator's clock count value via an interface, after encapsulating the interface function for real-time clock count reading within the target class library file, the clock count value of the heterogeneous accelerator can be read in real-time through the driver's interface by calling the interface function. The target class library file can be written using the HIP (Host Identity Protocol) standard syntax and C++ language to form a lightweight, single-source file library. Adding the target class library file to the heterogeneous accelerator's project code provides a time-dimensional executable tool for the heterogeneous accelerator through the class library file.

[0039] S102. Associate the interface function with at least one target code segment in the heterogeneous acceleration program so that when the heterogeneous acceleration program runs to the target code segment, it obtains the current clock count value through the interface function and stores the current clock count value in the target class library file.

[0040] The target code segment is the code section in the code file of the heterogeneous acceleration program that needs to be monitored for runtime. Based on the function type in the code, all functions or the code segments under one or more specific functions can be designated as target code segments, and a tracking point marker can be set for each target code segment. Each target code segment can include one or more lines of code. When the heterogeneous acceleration program runs to the code segment with the tracking point marker, it can obtain the current clock count value by calling the interface function in the target class library file and store the clock count value in the target class library file.

[0041] Specifically, start and end points can be set for each target code segment. That is, when the target code segment starts running, the aforementioned interface function is called based on the start point, and then the clock interface in the heterogeneous accelerator driver is accessed through the interface function to obtain the current clock count value. When the target code segment ends running, the aforementioned interface function is called based on the end point, and the current clock count value can also be obtained. Furthermore, if all target code segments are consecutive, a start point can be set only at the first target code segment, and an end point can be set for each target code segment, with the end point of the previous target code segment serving as the start point of the next target code segment. Optionally, in this embodiment of the invention, the method of instrumentation for the target code segments is not specifically limited.

[0042] S103. Compile and run the heterogeneous acceleration program to obtain the execution time of the target code segment through the clock count value stored in the target class library file.

[0043] After loading the target library file into the heterogeneous acceleration program, the heterogeneous acceleration program is compiled and then run. As described in the above technical solution, when the heterogeneous acceleration program runs to each target code segment, it will obtain the corresponding clock count value through the interface function. At the same time, since the clock of the heterogeneous accelerator starts from 0 and increments automatically after power-on, the later recorded clock value must be greater than the previously recorded clock value. The difference between two adjacent clock count values ​​is the running time of a target code segment.

[0044] Furthermore, by setting tracking points at the start and end of the heterogeneous acceleration program, the overall runtime of the program can be obtained, and the percentage of runtime of each target code segment in the overall runtime can be obtained. In particular, since the heterogeneous acceleration program runs in parallel with multiple physical threads, in order to avoid differences in physical performance between different threads, the runtime of each target code segment can be obtained only when the target thread executes the target code segment, based on a pre-specified target thread or a randomly obtained target thread, so as to avoid the impact of differences in code execution between different threads on the detection results.

[0045] Optionally, in this embodiment of the invention, compiling and running the heterogeneous acceleration program to obtain the execution time of the target code segment through the clock count value stored in the target class library file specifically includes: compiling and running the heterogeneous acceleration program to obtain the execution time of the target code segment in multiple target threads through the clock count value stored in the target class library file; wherein, the execution time includes at least one of the maximum execution time, the average execution time, and the minimum execution time.

[0046] Specifically, heterogeneous acceleration programs perform mathematical operations in a multi-threaded parallel execution manner. This can include multiple physical thread groups (e.g., 32 thread groups), each containing multiple physical threads (e.g., 64). A target code segment may be called by only one thread or by multiple threads. When writing the clock count value to the target library file, the target code segment also writes the thread identifier of the calling thread to the target library file. Therefore, for each target code segment, the execution time across all calling threads is obtained. The maximum execution time, average execution time, and minimum execution time reflect the worst, average, and best performance of a target code segment running in different threads, respectively, thus providing testers with a comprehensive basis for performance analysis.

[0047] Meanwhile, if the maximum execution time of the target code segment differs too much from the minimum execution time (e.g., greater than or equal to the first difference threshold), or if the maximum execution time differs too much from the average execution time (e.g., greater than or equal to the second difference threshold), it can also be determined that the physical thread corresponding to the maximum execution time has a performance anomaly, and further obtain the performance detection results of the physical structure of the heterogeneous accelerator.

[0048] Furthermore, although threads in each physical thread group can only execute the same computational task, different physical thread groups can execute different computational tasks, and each thread group may call some or all of its internal threads when executing a computational task. Therefore, a heterogeneous acceleration program can be configured with only one data processing task, or no data processing task can be configured to run in an idle state; or multiple data processing tasks can be configured for the heterogeneous acceleration program so that different thread groups execute different data processing tasks. This also allows us to obtain the target code segment and its maximum, average, and minimum execution time under different data processing tasks.

[0049] Optionally, in this embodiment of the invention, compiling and running the heterogeneous acceleration program to obtain the execution time of the target code segment in multiple target threads through the clock count value stored in the target class library file specifically includes: if the proportion of the number of called threads in the current thread group is greater than or equal to a first proportion threshold, then the called threads in the current thread group are taken as target threads; if the proportion of the number of called threads in the current thread group is less than the first proportion threshold, then the called threads in the current thread group are taken as non-target threads.

[0050] Specifically, if a data processing task has a small computational load, the calculation can be completed by calling only one or a limited number of threads in a thread group. However, since the purpose of heterogeneous accelerators is to perform complex mathematical operations, if there are few threads called in the current thread group, the execution time of each target code segment in the thread cannot truly reflect its performance. Therefore, if the number of threads called in the current thread group is small, the threads in the thread group are not used as target threads. This avoids the distortion of execution time when the current thread is processing overly simple data calculation tasks, which would lead to obtaining erroneous execution time data that differs greatly from the actual data processing task, thus improving the accuracy of detecting the execution time of the target code segment.

[0051] Optionally, in this embodiment of the invention, the step of compiling and running the heterogeneous acceleration program to obtain the running time of the target code segment through the clock count value stored in the target class library file further includes: constructing different types of data processing tasks according to the data volume, data type, and calculation method; and compiling and running the heterogeneous acceleration program based on the different types of data processing tasks to obtain the running time of the target code segment under each of the data processing tasks through the clock count value stored in the target class library file.

[0052] Specifically, data volume refers to the size of the data to be processed in a data processing task. Taking a matrix operation task processed by a heterogeneous accelerator as an example, data volume refers to the order of the matrix to be operated on, such as a 16th-order square matrix, a 32nd-order square matrix, and a 64th-order square matrix. Data type refers to the type of data to be processed, including floating-point data and integer data. For matrix operation tasks, data type refers to the data type of each element in the matrix. Calculation method refers to the mathematical operation between two or more data to be processed, such as multiplication and addition. By constructing different types of data processing tasks through data volume, data type, and calculation method, different data processing tasks can be executed in parallel by different thread groups. This enables the acquisition of the runtime of the target code segment under different types of data processing tasks, further expanding the performance testing range of the target code segment. For example, when target code segment A performs a multiplication operation between two floating-point 32nd-order square matrices, the runtime is time B.

[0053] Meanwhile, based on the execution time of the target code segment under different types of data processing tasks, the computational bottleneck of each data processing task can also be obtained, providing a data foundation for further improving the computational efficiency of heterogeneous acceleration programs. For example, when the target code segment C performs a multiplication operation between two integer square matrices, the execution time is relatively short for square matrices of order 32 and below, but the execution time increases significantly for square matrices of order 32 and above.

[0054] Optionally, in this embodiment of the invention, before adding the target class library file to the heterogeneous acceleration program to be detected, the method includes: determining the abnormal function based on the execution time of each function in the heterogeneous acceleration program, and setting the code segment in the abnormal function as the target code segment; wherein, the proportion of the execution time of the abnormal function in the execution time of the heterogeneous acceleration program is greater than or equal to a second proportion threshold, or the execution time of the abnormal function is greater than or equal to a first time threshold.

[0055] Specifically, performance testing tools, such as "rocprof" mentioned in the above technical solution, can be used to perform preliminary performance analysis on heterogeneous accelerated programs, obtain the execution time of each function, and the proportion of each function's execution time in the overall execution time. Based on this, abnormal functions with long execution times or high execution time proportions are first identified. Then, all code segments included in the abnormal functions can be used as target code segments, or one or more pre-specified code segments under each abnormal function can be used as target code segments according to different function types. Thus, after the preliminary detection of function execution time is completed based on the performance testing tool, the execution time of key code segments under the abnormal functions with long execution times is monitored. This achieves targeted annotation of target code segments, avoids the existence of too many target code segments, which would reduce the performance testing efficiency of heterogeneous accelerated programs, and improves the accuracy of execution time detection results.

[0056] The technical solution of this invention involves adding the target class library file to the heterogeneous acceleration program to be tested and associating the interface function with the target code segment in the heterogeneous acceleration program. The heterogeneous acceleration program is then compiled and run. When the heterogeneous acceleration program reaches the target code segment, it obtains the current clock count value through the interface function and stores it in the target class library file. Then, the execution time of the target code segment is obtained through the clock count value stored in the target class library file. This not only achieves the detection of the execution time of specific code segments in the heterogeneous acceleration program, improving the performance detection accuracy of the heterogeneous acceleration program, but also, compared to the frequent process interactions between traditional performance testing tools and heterogeneous acceleration programs, the heterogeneous acceleration program in this embodiment only needs to perform the clock count value acquisition and storage operation through the interface function, having minimal impact on the execution time of the heterogeneous acceleration program. This avoids distortion of function execution time and greatly improves the accuracy of the obtained performance results.

[0057] Example 2

[0058] Figure 2 This is a flowchart of a performance detection method for a heterogeneous acceleration program provided in Embodiment 2 of the present invention. The relationship between this embodiment and the above embodiments is that, based on the time consumption correlation of various types of data processing tasks, it is determined whether there are any runtime anomalies in the target code segment. Figure 2 As shown, the method includes:

[0059] S201. Add the target class library file to the heterogeneous accelerator program to be detected; wherein, the target class library file includes interface functions for reading the clock count value of the heterogeneous accelerator.

[0060] S202. Associate the interface function with at least one target code segment in the heterogeneous acceleration program so that when the heterogeneous acceleration program runs to the target code segment, it obtains the current clock count value through the interface function and stores the current clock count value in the target class library file.

[0061] S203. Based on the data type and calculation method, construct different types of data processing tasks and obtain the time consumption correlation of each type of data processing task; wherein, the time consumption correlation reflects the proportional relationship between the running time corresponding to different data volumes.

[0062] Taking the above technical solution as an example, the multiplication task between two floating-point 32-order square matrices can actually be broken down into the multiplication task between four 16-order square matrices. The summation of the product results only requires a small amount of computation time. Therefore, for the multiplication task between floating-point matrices, the running time of the 32-order square matrix is ​​4 times or slightly more than 4 times that of the 16-order square matrix (for example, 4.1 times). Similarly, there are corresponding time-consuming relationships between other data volumes under this task type, as well as between other types of data processing tasks. Thus, the pre-constructed time-consuming relationships can be obtained.

[0063] S204. Based on different types of data processing tasks, compile and run the heterogeneous acceleration program to obtain the running time of the target code segment under different data amounts in each data processing task through the clock count value stored in the target class library file.

[0064] S205. If the running time of the target code segment under different data volumes in the target data processing task conforms to the corresponding time consumption correlation, then it is determined that the target code segment has an abnormal running time.

[0065] For a certain type of data processing task, the amount of data to be processed is changed. For example, in the multiplication calculation task between the two floating-point matrices mentioned above, the amount of data is set to 8-order square matrix, 16-order square matrix, 32-order square matrix, 64-order square matrix and 128-order square matrix respectively; the running time of the target code segment under different amounts of data in this type of data processing task is obtained, and it is determined whether the above running time conforms to the corresponding time correlation relationship.

[0066] If the execution time of the target code segment under various data volumes in the target data processing task conforms to the expected time correlation mentioned above, it indicates that the target code segment is running normally; if the execution time of the target code segment under various data volumes in the target data processing task does not conform to the expected time correlation mentioned above, it indicates that the target code segment is running abnormally. Therefore, according to different data types and calculation methods, by matching the execution time between different data volumes with the corresponding time correlation in different types of data processing tasks, it is possible not only to detect whether the target code segment has excessive execution time in each type of data processing task, but also to obtain the specific data volume when the excessive execution time occurs. This provides necessary data support for the testers to optimize the code of the target code segment.

[0067] The technical solution of this invention, after constructing different types of data processing tasks according to data type and calculation method, obtains the running time of the target code segment under different data amounts in each data processing task, and then determines whether the running time of the target code segment under different data amounts in the target data processing task conforms to the corresponding time consumption correlation. When the time consumption correlation is met, it is determined that the target code segment has an abnormal running time. This not only detects whether the target code segment has excessive running time in each data processing task, but also obtains the specific data amount when the excessive running time occurs, thus providing necessary data support for the testing personnel to optimize the code of the target code segment.

[0068] Example 3

[0069] Figure 3 This is a flowchart of a performance detection method for a heterogeneous acceleration program provided in Embodiment 3 of the present invention. In this embodiment, if the execution time of the target code segment under different data volumes in the target data processing task does not conform to the corresponding time consumption correlation, then it is further determined whether the execution time of the first data volume and the execution time of the second data volume in other types of data processing tasks conform to the corresponding time consumption correlation. Figure 3 As shown, the method includes:

[0070] S301. Add the target class library file to the heterogeneous accelerator program to be detected; wherein, the target class library file includes interface functions for reading the clock count value of the heterogeneous accelerator.

[0071] S302. Associate the interface function with at least one target code segment in the heterogeneous acceleration program so that when the heterogeneous acceleration program runs to the target code segment, it obtains the current clock count value through the interface function and stores the current clock count value in the target class library file.

[0072] S303. Based on the data type and calculation method, construct different types of data processing tasks and obtain the time consumption correlation of each type of data processing task; wherein, the time consumption correlation reflects the proportional relationship between the running time corresponding to different data volumes.

[0073] S304. Based on different types of data processing tasks, compile and run the heterogeneous acceleration program to obtain the running time of the target code segment under different data amounts in each data processing task through the clock count value stored in the target class library file.

[0074] S305. If the running time of the target code segment under different data amounts in the target data processing task does not conform to the corresponding time consumption correlation, then obtain the first data amount and the second data amount that do not conform to the time consumption correlation.

[0075] S306. Determine whether the running time of the first data volume and the running time of the second data volume in other types of data processing tasks conform to the corresponding time correlation relationship; if not, execute S307; if yes, execute S308.

[0076] Taking the above technical solution as an example, if the running time of the multiplication calculation task between two floating-point 32-order square matrices does not conform to the expected ratio of the running time of the multiplication calculation task between two floating-point 16-order square matrices, then the 16-order square matrix and the 32-order square matrix are respectively the first data volume and the second data volume. Therefore, in other types of data processing tasks, namely, in the multiplication calculation task between two integer square matrices, the addition calculation task between two integer square matrices, and / or the addition calculation task between two floating-point square matrices, it is determined whether the running time between the 16-order square matrix and the 32-order square matrix conforms to their respective ratios.

[0077] S306. It is determined that the heterogeneous acceleration program has an abnormal running time for either the first data volume or the second data volume.

[0078] If, in other types of data processing tasks, the execution time of the first data volume and the execution time of the second data volume in at least one task do not conform to the corresponding time correlation, it indicates that the abnormal execution time of the target code segment has occurred in multiple data processing tasks due to the excessively large or small data volume. In other words, the abnormal execution time of the target code segment is related to the first or second data volume.

[0079] S307. It is determined that the abnormal acceleration program has an abnormal running time for the target data processing task.

[0080] If the execution time of the first data volume and the execution time of the second data volume in other types of data processing tasks both conform to the corresponding time consumption correlation, it indicates that the execution time anomaly in the target code segment is not due to the data volume being too large or too small, but rather an execution anomaly has occurred for a specific type of data processing task.

[0081] The technical solution of this invention, after determining that the running time of the target code segment under different data volumes in the target data processing task does not conform to the corresponding time consumption correlation, further determines whether the running time of the first data volume and the running time of the second data volume in other types of data processing tasks conform to the corresponding time consumption correlation. This further determines whether the abnormal running time of the target code segment is due to the data volume being too large or too small, or whether it only occurs when processing specific types of data processing tasks, thus further ensuring the accuracy of the performance detection results of the heterogeneous acceleration program.

[0082] Example 4

[0083] Figure 4 This is a structural block diagram of a performance testing device for heterogeneous acceleration programs provided in Embodiment 4 of the present invention. The device specifically includes:

[0084] The file addition execution module 401 is used to add target class library files to the heterogeneous acceleration program to be detected; wherein, the target class library files include interface functions for reading the clock count values ​​of the heterogeneous accelerator;

[0085] The execution association module 402 is used to associate the interface function with at least one target code segment in the heterogeneous acceleration program, so that when the heterogeneous acceleration program runs to the target code segment, it obtains the current clock count value through the interface function and stores the current clock count value in the target class library file;

[0086] The runtime acquisition module 403 is used to compile and run the heterogeneous acceleration program to acquire the runtime of the target code segment through the clock count value stored in the target class library file.

[0087] The technical solution of this invention involves adding the target class library file to the heterogeneous acceleration program to be tested and associating the interface function with the target code segment in the heterogeneous acceleration program. The heterogeneous acceleration program is then compiled and run. When the heterogeneous acceleration program reaches the target code segment, it obtains the current clock count value through the interface function and stores it in the target class library file. Then, the execution time of the target code segment is obtained through the clock count value stored in the target class library file. This not only achieves the detection of the execution time of specific code segments in the heterogeneous acceleration program, improving the performance detection accuracy of the heterogeneous acceleration program, but also, compared to the frequent process interactions between traditional performance testing tools and heterogeneous acceleration programs, the heterogeneous acceleration program in this embodiment only needs to perform the clock count value acquisition and storage operation through the interface function, having minimal impact on the execution time of the heterogeneous acceleration program. This avoids distortion of function execution time and greatly improves the accuracy of the obtained performance results.

[0088] Optionally, the runtime acquisition module 403 is specifically used to compile and run the heterogeneous acceleration program to acquire the runtime of the target code segment in multiple target threads through the clock count value stored in the target class library file; wherein, the runtime includes at least one of the maximum runtime, average runtime, and minimum runtime.

[0089] Optionally, the runtime acquisition module 403 is further used to: if the percentage of the number of called threads in the current thread group is greater than or equal to a first percentage threshold, then the called threads in the current thread group are taken as target threads; if the percentage of the number of called threads in the current thread group is less than the first percentage threshold, then the called threads in the current thread group are taken as non-target threads.

[0090] Optionally, the runtime acquisition module 403 is further configured to construct different types of data processing tasks based on the data volume, data type, and calculation method; and to compile and run the heterogeneous acceleration program based on the different types of data processing tasks, so as to obtain the runtime of the target code segment under each of the data processing tasks through the clock count value stored in the target class library file.

[0091] Optionally, the runtime acquisition module 403 is further configured to construct different types of data processing tasks based on data type and calculation method, and acquire the runtime correlation of each type of data processing task; wherein, the runtime correlation reflects the proportional relationship between runtimes corresponding to different data volumes; based on different types of data processing tasks, the heterogeneous acceleration program is compiled and run to acquire the runtime of the target code segment under different data volumes in each of the data processing tasks through the clock count value stored in the target class library file; if the runtime of the target code segment under different data volumes in the target data processing task conforms to the corresponding runtime correlation, it is determined that the target code segment does not have runtime anomalies.

[0092] Optionally, the performance testing device for heterogeneous acceleration programs also includes:

[0093] The runtime anomaly detection module is used to: if the runtime of the target code segment under different data volumes in the target data processing task does not conform to the corresponding runtime correlation, then obtain the first and second data volumes that do not conform to the runtime correlation; determine whether the runtime of the first data volume and the runtime of the second data volume in other types of data processing tasks conform to the corresponding runtime correlation; if they do not conform to the runtime correlation, then determine that the heterogeneous acceleration program has a runtime anomaly for the first data volume or the second data volume; if they conform to the runtime correlation, then determine that the abnormal acceleration program has a runtime anomaly for the target data processing task.

[0094] Optionally, the performance testing device for heterogeneous acceleration programs also includes:

[0095] The target code segment acquisition module is used to determine the abnormal function based on the execution time of each function in the heterogeneous acceleration program, and set the code segment in the abnormal function as the target code segment; wherein, the proportion of the execution time of the abnormal function in the execution time of the heterogeneous acceleration program is greater than or equal to a second proportion threshold, or the execution time of the abnormal function is greater than or equal to a first time threshold.

[0096] The above-described apparatus can execute the performance testing method for heterogeneous acceleration programs provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method. Technical details not described in detail in this embodiment can be found in the performance testing method for heterogeneous acceleration programs provided in any embodiment of the present invention.

[0097] Example 5

[0098] Figure 5A schematic diagram of an electronic device 10 that can be used to implement embodiments of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.

[0099] like Figure 5 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 may also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0100] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0101] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as performance testing methods for heterogeneous acceleration programs.

[0102] In some embodiments, the performance testing method for heterogeneous acceleration programs can be implemented as a computer program tangibly contained in a computer-readable storage medium, such as a storage unit. In some embodiments, part or all of the computer program can be loaded and / or installed onto the heterogeneous hardware accelerator via ROM and / or a communication unit. When the computer program is loaded into RAM and executed by a processor, one or more steps of the performance testing method for heterogeneous acceleration programs described above can be performed. Alternatively, in other embodiments, the processor can be configured to perform the performance testing method for heterogeneous acceleration programs by any other suitable means (e.g., by means of firmware).

[0103] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0104] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0105] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0106] To provide user interaction, the systems and techniques described herein can be implemented on a heterogeneous hardware accelerator, which includes: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the heterogeneous hardware accelerator. Other types of devices can also be used to provide user interaction; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or haptic feedback); and input from the user can be received in any form (including sound input, voice input, or haptic input).

[0107] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.

[0108] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.

[0109] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.

[0110] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.

Claims

1. A performance testing method for heterogeneous acceleration programs, characterized in that, include: Add the target library file to the heterogeneous accelerator to be detected; wherein, the target library file includes interface functions for reading the clock count value of the heterogeneous accelerator; The interface function is associated with at least one target code segment in the heterogeneous acceleration program so that when the heterogeneous acceleration program runs to the target code segment, it obtains the current clock count value through the interface function and stores the current clock count value in the target class library file. Compile and run the heterogeneous acceleration program to obtain the execution time of the target code segment through the clock count value stored in the target class library file; The step of compiling and running the heterogeneous acceleration program to obtain the execution time of the target code segment through the clock count value stored in the target class library file specifically includes: Compile and run the heterogeneous acceleration program to obtain the execution time of the target code segment in multiple target threads through the clock count value stored in the target class library file; wherein, the execution time includes at least one of the maximum execution time, average execution time, and minimum execution time; Specifically, compiling and running the heterogeneous acceleration program to obtain the execution time of the target code segment in multiple target threads using the clock count value stored in the target class library file includes: If the proportion of called threads in the current thread group is greater than or equal to the first proportion threshold, then the called threads in the current thread group will be used as the target threads. If the percentage of called threads in the current thread group is less than the first percentage threshold, then the called threads in the current thread group will be treated as non-target threads.

2. The method according to claim 1, characterized in that, The process of compiling and running the heterogeneous acceleration program to obtain the execution time of the target code segment using the clock count value stored in the target class library file further includes: Based on the data volume, data type, and calculation method, different types of data processing tasks can be constructed; Based on different types of data processing tasks, the heterogeneous acceleration program is compiled and run to obtain the running time of the target code segment under each data processing task through the clock count value stored in the target class library file.

3. The method according to claim 1, characterized in that, The process of compiling and running the heterogeneous acceleration program to obtain the execution time of the target code segment using the clock count value stored in the target class library file further includes: Based on data type and calculation method, different types of data processing tasks are constructed, and the time consumption correlation of each type of data processing task is obtained; wherein, the time consumption correlation reflects the proportional relationship between the running time corresponding to different data volumes; Based on different types of data processing tasks, the heterogeneous acceleration program is compiled and run to obtain the running time of the target code segment under different data volumes in each data processing task by using the clock count value stored in the target class library file. If the execution time of the target code segment under different data volumes in the target data processing task conforms to the corresponding time consumption correlation, then it is determined that the target code segment does not have any execution time anomalies.

4. The method according to claim 3, characterized in that, After compiling and running the heterogeneous acceleration program based on different types of data processing tasks, and obtaining the running time of the target code segment under different data volumes in each data processing task through the clock count value stored in the target class library file, the method further includes: If the execution time of the target code segment under different data volumes in the target data processing task does not conform to the corresponding time consumption correlation, then the first data volume and the second data volume that do not conform to the time consumption correlation are obtained. Determine whether the execution time of the first data volume and the execution time of the second data volume in other types of data processing tasks conform to the corresponding time correlation relationship; If the time consumption correlation is not met, it is determined that the heterogeneous acceleration program has an abnormal running time for the first data volume or the second data volume; If the time consumption correlation is found, it is determined that the heterogeneous acceleration program has an abnormal running time for the target data processing task.

5. The method according to claim 1, characterized in that, Before adding the target library files to the heterogeneous accelerator to be detected, the following should be included: The abnormal function is determined based on the execution time of each function in the heterogeneous acceleration program, and the code segment in the abnormal function is set as the target code segment; wherein, the proportion of the execution time of the abnormal function in the execution time of the heterogeneous acceleration program is greater than or equal to a second proportion threshold, or the execution time of the abnormal function is greater than or equal to a first time threshold.

6. A performance testing device for heterogeneous acceleration programs, characterized in that, include: The file addition execution module is used to add target library files to the heterogeneous acceleration program to be detected; wherein, the target library files include interface functions for reading the clock count values ​​of the heterogeneous accelerator; The execution association module is used to associate the interface function with at least one target code segment in the heterogeneous acceleration program, so that when the heterogeneous acceleration program runs to the target code segment, it obtains the current clock count value through the interface function and stores the current clock count value in the target class library file; The runtime acquisition module is used to compile and run the heterogeneous acceleration program to acquire the runtime of the target code segment through the clock count value stored in the target class library file; The runtime acquisition module is specifically used to: compile and run the heterogeneous acceleration program to acquire the runtime of the target code segment in multiple target threads through the clock count value stored in the target class library file; wherein the runtime includes at least one of the maximum runtime, average runtime, and minimum runtime. The runtime acquisition module is further configured to: if the proportion of the number of called threads in the current thread group is greater than or equal to a first proportion threshold, then the called threads in the current thread group are taken as target threads; if the proportion of the number of called threads in the current thread group is less than the first proportion threshold, then the called threads in the current thread group are taken as non-target threads.

7. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the performance testing method of the heterogeneous acceleration program according to any one of claims 1-5.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that cause a processor to execute the performance testing method of the heterogeneous acceleration program according to any one of claims 1-5.