Method and device for evaluating use condition of acceleration instruction set and electronic equipment

By acquiring and analyzing the accelerated instruction set distribution and dynamic processing information of the target application, and combining dynamic binary instrumentation and virtualization layer monitoring technologies, the problem of low evaluation efficiency in existing technologies is solved, and a more comprehensive evaluation effect is achieved.

CN121579079APending Publication Date: 2026-02-27HYGON INFORMATION TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202511783357.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-28
Publication Date
2026-02-27

AI Technical Summary

Technical Problem

Existing technology evaluation software is inefficient and prone to omissions in assessing the use of acceleration instruction sets, and cannot effectively improve evaluation results.

Method used

By obtaining the application file of the target application, the distribution information and dynamic processing information of the instructions in the preset acceleration instruction set in the application file are determined. The distribution information and dynamic processing information are combined for evaluation, and dynamic binary instrumentation technology and virtualization layer monitoring technology are used for instruction monitoring.

Benefits of technology

It enables a comprehensive assessment of the usage of the acceleration instruction set, improving assessment efficiency and reducing the time and effort required for manual inspection and debugging.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121579079A_ABST
    Figure CN121579079A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses an evaluation method and device for the use condition of an acceleration instruction set and electronic equipment, relates to the technical field of computers, and can improve the evaluation efficiency of the use of the acceleration instruction set and effectively improve the evaluation effect. The method comprises the steps of obtaining an application file of a target application, wherein the application file comprises a source code file and / or a binary file; determining distribution information of instructions in a preset acceleration instruction set in the application file and determining dynamic processing information of the instructions in the preset acceleration instruction set during operation of the target application; and according to the distribution information and the dynamic processing information, evaluating the use condition of the preset acceleration instruction set by the target application. The method is suitable for software optimization and software performance evaluation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a method, apparatus, electronic device, and storage medium for evaluating the use of accelerated instruction sets. Background Technology

[0002] In the field of modern high-performance computing (HPC), software performance is closely related to the efficiency of utilizing the underlying processor instruction set. With the development of processor technology, such as the x86 architecture's central processing unit (CPU), a variety of dedicated acceleration instruction sets are commonly integrated. These include Single Instruction Multiple Data (SIMD) instruction sets (such as SSE (Streaming SIMD Extensions), AVX (Advanced Vector Extensions), and AVX2 (Advanced Vector Extensions 2), encryption instructions (such as AES-NI (Advanced Encryption Standard New Instructions), compression instructions, bit manipulation instructions (such as BMI (Bit Manipulation Instructions) and BMI2 (Bit Manipulation Instructions 2), and Fused Multiply-Add (FMA) instructions. These instructions can complete specific computational tasks more efficiently, such as processing large amounts of data in parallel, performing encryption and decryption operations, and performing bitwise operations, thereby significantly improving the software's running speed and overall performance. Accordingly, understanding whether these acceleration instruction sets are used in the software and the extent to which they are used is also beneficial for software performance optimization.

[0003] In related technologies, the main way to evaluate the software’s use of the acceleration instruction set is by having engineers check or debug the assembly code. This not only requires a lot of time and effort but is also prone to omissions, resulting in low evaluation efficiency and poor evaluation results. Summary of the Invention

[0004] In view of this, embodiments of the present invention provide a method, apparatus, electronic device, and storage medium for evaluating the use of accelerated instruction sets, which can greatly improve the evaluation efficiency of accelerated instruction set usage and effectively improve the evaluation results.

[0005] In a first aspect, embodiments of the present invention provide a method for evaluating the usage of an accelerated instruction set, comprising: obtaining an application file of a target application, the application file including source code files and / or binary files; determining the distribution information of instructions in a preset accelerated instruction set in the application file and determining the dynamic processing information of the instructions in the preset accelerated instruction set during the operation of the target application; and evaluating the usage of the preset accelerated instruction set by the target application based on the distribution information and the dynamic processing information.

[0006] In one embodiment, the application file includes a source code file; the distribution information includes first distribution information of instructions in the preset acceleration instruction set in the source code file; determining the distribution information of instructions in the preset acceleration instruction set in the application file includes: determining whether the source code file contains a first target of interest according to a preset matching rule, the first target of interest including at least one of the following: preset compilation flags, preset inline functions, preset function libraries; if the source code file contains the first target of interest, searching for acceleration instructions associated with the first target of interest in the source code file to obtain the first acceleration instructions; and statistically analyzing the distribution of the first acceleration instructions in the source code file to obtain the first distribution information.

[0007] In one embodiment, the application file includes a binary file; the distribution information includes second distribution information of instructions in the preset acceleration instruction set in the binary file; determining the distribution information of instructions in the preset acceleration instruction set in the application file includes: disassembling the binary file to obtain a disassembled code file of the target application; searching for instructions in the preset acceleration instruction set in the disassembled code file according to a preset matching rule to obtain second acceleration instructions; and statistically analyzing the distribution of the second acceleration instructions in the disassembled code file to obtain the second distribution information.

[0008] In one embodiment, determining the dynamic processing information of the instructions in the preset acceleration instruction set during the execution of the target application includes: detecting the dynamic link libraries loaded during the execution of the target application to obtain a target link library; disassembling the target link library to obtain a disassembled link library; searching for instructions in the preset acceleration instruction set in the disassembled link library according to a preset matching rule to obtain a third acceleration instruction; and generating dynamic processing information of the instructions in the preset acceleration instruction set during the execution of the target application based on the third acceleration instruction, wherein the dynamic processing information includes loading information.

[0009] In one implementation, detecting the dynamic link libraries loaded during the execution of the target application to obtain the target link library includes: obtaining the dynamic link libraries directly called during the execution of the target application through a preset instruction, and adding the dynamic link libraries to a dynamic library queue; sequentially detecting whether each dynamic link library in the dynamic library queue has dependent dynamic link libraries in a first-in-first-out (FIFO) order; in response to any dynamic link library having dependent dynamic link libraries, adding the dependent dynamic link libraries to the dynamic library queue; jumping back to the step of sequentially detecting whether each dynamic link library in the dynamic library queue has dependent dynamic link libraries in a FIFO order and continuing to execute, iterating in a loop until all dynamic link libraries in the dynamic library queue have been detected; and using all the detected dynamic link libraries as the target link library.

[0010] In one implementation, determining the dynamic processing information of the instructions in the preset acceleration instruction set during the operation of the target application includes: determining the dynamic processing information of the instructions in the preset acceleration instruction set during the operation of the target application based on runtime instruction monitoring technology.

[0011] In one embodiment, the runtime instruction monitoring technology includes dynamic binary instrumentation technology; determining the dynamic processing information of instructions in the preset acceleration instruction set during the execution of the target application based on the runtime instruction monitoring technology includes: inserting a first callback function and a second callback function into the target application based on the dynamic binary instrumentation (DBI) technology; before each instruction of the target application is executed, calling the first callback function to detect whether the instruction is an instruction in the preset acceleration instruction set and obtaining a detection result; after the target application finishes running, calling the second callback function to generate dynamic processing information of instructions in the preset acceleration instruction set during the execution of the target application based on the detection results of each instruction, wherein the dynamic processing information includes execution information.

[0012] In one embodiment, the runtime instruction monitoring technology includes: virtualization layer monitoring technology; determining the dynamic processing information of instructions in the preset acceleration instruction set during the execution of the target application based on the runtime instruction monitoring technology includes: running the target application in a virtual machine environment; using a virtual machine monitor (VMM) (or hypervisor) to intercept instruction execution or specific hardware events during the execution of the target application; analyzing the opcode of the current instruction during the interception phase, detecting whether the instruction is an instruction in the preset acceleration instruction set, and obtaining a detection result; generating dynamic processing information of instructions in the preset acceleration instruction set during the execution of the target application based on the detection results of each instruction, wherein the dynamic processing information includes execution information.

[0013] In one implementation, detecting whether the instruction is an instruction in the preset acceleration instruction set and obtaining the detection result includes: obtaining the opcode or disassembled text of the current instruction to obtain the disassembled instruction; determining whether the disassembled instruction matches an instruction in the preset acceleration instruction set according to a preset matching rule; in response to the disassembled instruction matching an instruction in the preset acceleration instruction set, determining that the current instruction is an instruction in the preset acceleration instruction set and recording the association information of the current instruction to obtain the detection result, wherein the association information includes at least one of the following: the memory address of the current instruction, the program module to which the current instruction belongs, the function to which the current instruction belongs, the number of times the current instruction has been executed, the execution frequency, the cumulative number of execution cycles, context information, and the time percentage in the execution of the target application.

[0014] In one implementation, the distribution information includes at least one of the following: the instruction type to which the instruction in the preset acceleration instruction set belongs, the position of the instruction in the preset acceleration instruction set in the application file, and the number of times the instruction in the preset acceleration instruction set appears in the application file.

[0015] In one implementation, evaluating the target application's usage of the preset acceleration instruction set based on the distribution information and the dynamic processing information includes: integrating the distribution information and the dynamic processing information; and generating a visual report on the target application's usage of the preset acceleration instruction set based on the integration result.

[0016] In one embodiment, integrating the distribution information with the dynamic processing information includes: comparing the distribution information with the dynamic processing information; for any instruction in the preset acceleration instruction set, if the distribution information contains the instruction and the dynamic processing information does not contain the instruction, determining that the instruction is in an unexecuted code path; for any instruction in the preset acceleration instruction set, if the distribution information does not contain the instruction and the dynamic processing information contains the instruction, determining that the instruction is a runtime-generated instruction or a dynamically loaded instruction.

[0017] In one implementation, the visualization report includes: the distribution information, the dynamic processing information, a comparison result between the distribution information and the dynamic processing information, and hierarchical classification statistics.

[0018] Secondly, embodiments of the present invention also provide an evaluation apparatus for the use of an acceleration instruction set, comprising: an acquisition unit for acquiring an application file of a target application, the application file including source code files and / or binary files; a determination unit for determining distribution information of instructions in a preset acceleration instruction set in the application file and determining dynamic processing information of instructions in the preset acceleration instruction set during the operation of the target application; and an evaluation unit for evaluating the use of the preset acceleration instruction set by the target application based on the distribution information and the dynamic processing information.

[0019] In one embodiment, the application file includes a source code file; the distribution information includes first distribution information of instructions in the preset acceleration instruction set in the source code file; the determining unit includes: a first determining module, configured to determine whether the source code file contains a first target of interest according to a preset matching rule, the first target of interest including at least one of the following: a preset compilation flag, a preset inline function, a preset function library; a first searching module, configured to search for acceleration instructions associated with the first target of interest in the source code file when the source code file contains the first target of interest, to obtain the first acceleration instructions; and a first statistics module, configured to perform statistics on the distribution of the first acceleration instructions in the source code file to obtain the first distribution information.

[0020] In one embodiment, the application file includes a binary file; the distribution information includes second distribution information of instructions in the preset acceleration instruction set within the binary file; the determining unit includes: a first disassembly module, configured to disassemble the binary file to obtain a disassembled code file of the target application; a second search module, configured to search for instructions in the preset acceleration instruction set within the disassembled code file according to preset matching rules to obtain second acceleration instructions; and a second statistics module, configured to statistically analyze the distribution of the second acceleration instructions within the disassembled code file to obtain the second distribution information.

[0021] In one embodiment, the determining unit includes: a first detection module, configured to detect dynamic link libraries loaded during the execution of the target application, and obtain a target link library; a second disassembly module, configured to disassemble the target link library, and obtain a disassembled link library; a third search module, configured to search for instructions in the disassembled link library according to preset matching rules, and obtain a third acceleration instruction; and a first generation module, configured to generate dynamic processing information of the instructions in the preset acceleration instruction set during the execution of the target application according to the third acceleration instruction, wherein the dynamic processing information includes loading information.

[0022] In one implementation, the first detection module is specifically configured to: obtain the dynamic link libraries directly called during the execution of the target application through a preset instruction, and add the dynamic link libraries to a dynamic library queue; sequentially detect whether each dynamic link library in the dynamic library queue has dependent dynamic link libraries in a first-in-first-out (FIFO) order; in response to any dynamic link library having dependent dynamic link libraries, add the dependent dynamic link libraries to the dynamic library queue; jump back to the step of sequentially detecting whether each dynamic link library in the dynamic library queue has dependent dynamic link libraries in a first-in-first-out (FIFO) order, and continue execution, iterating until all dynamic link libraries in the dynamic library queue have been detected; and use all the detected dynamic link libraries as the target link libraries.

[0023] In one implementation, the determining unit is specifically used to determine the dynamic processing information of the instructions in the preset acceleration instruction set during the operation of the target application based on runtime instruction monitoring technology.

[0024] In one implementation, the runtime instruction monitoring technology includes dynamic binary instrumentation; the determining unit includes: an insertion module, used to insert a first callback function and a second callback function into the target application based on the dynamic binary instrumentation; a first calling module, used to call the first callback function before the execution of each instruction in the target application, to detect whether the instruction is an instruction in the preset acceleration instruction set, and to obtain a detection result; a second calling module, used to call the second callback function after the target application finishes running, and to generate dynamic processing information of the instructions in the preset acceleration instruction set during the running of the target application based on the detection results of each instruction. The dynamic processing information includes execution information; or, the runtime instruction monitoring technology includes: virtualization layer monitoring technology; the determining unit includes: a running module, used to run the target application in a virtual machine environment; an interception module, used to intercept instruction execution or specific hardware events during the runtime of the target application using a virtual machine monitor; an analysis module, used to analyze the opcode of the current instruction during the interception phase, detect whether the instruction is an instruction in the preset acceleration instruction set, and obtain a detection result; a second generation module, used to generate dynamic processing information of the instructions in the preset acceleration instruction set during the runtime of the target application based on the detection results of each instruction, the dynamic processing information including execution information.

[0025] In one implementation, the first calling module or the analysis module is specifically configured to: obtain the opcode or disassembled text of the current instruction to obtain the disassembled instruction; determine whether the disassembled instruction matches an instruction in the preset acceleration instruction set according to a preset matching rule; in response to the disassembled instruction matching an instruction in the preset acceleration instruction set, determine that the current instruction is an instruction in the preset acceleration instruction set and record the association information of the current instruction to obtain the detection result, wherein the association information includes at least one of the following: the memory address of the current instruction, the program module to which the current instruction belongs, the function to which the current instruction belongs, the number of times the current instruction is executed, the execution frequency, the cumulative number of execution cycles, context information, and the time percentage in the execution of the target application.

[0026] In one implementation, the distribution information includes at least one of the following: the instruction type to which the instruction in the preset acceleration instruction set belongs, the position of the instruction in the preset acceleration instruction set in the application file, and the number of times the instruction in the preset acceleration instruction set appears in the application file.

[0027] In one embodiment, the evaluation unit includes: an integration module for integrating the distribution information with the dynamic processing information; and a second generation module for generating a visualization report on the target application's usage of the preset acceleration instruction set based on the integration result.

[0028] In one implementation, the integration module is specifically configured to: compare the distribution information with the dynamic processing information; for any instruction in the preset acceleration instruction set, if the distribution information contains the instruction and the dynamic processing information does not contain the instruction, determine that the instruction is in an unexecuted code path; for any instruction in the preset acceleration instruction set, if the distribution information does not contain the instruction and the dynamic processing information contains the instruction, determine that the instruction is a runtime-generated instruction or a dynamically loaded instruction.

[0029] In one implementation, the visualization report includes: the distribution information, the dynamic processing information, a comparison result between the distribution information and the dynamic processing information, and hierarchical classification statistics.

[0030] Thirdly, embodiments of the present invention also provide an electronic device, the electronic device comprising: a processor and a memory, the processor being electrically connected to the memory; the memory being used to store executable program code; the processor running a program corresponding to the executable program code by reading the executable program code stored in the memory, thereby implementing any of the acceleration instruction set usage evaluation methods provided by embodiments of the present invention.

[0031] Fourthly, embodiments of the present invention also provide a computer-readable storage medium storing one or more programs that can be executed by one or more processors to implement any of the methods for evaluating the use of accelerated instruction sets provided in embodiments of the present invention.

[0032] The embodiments of the present invention provide a method, apparatus, electronic device, and storage medium for evaluating the usage of accelerated instruction sets. These methods can acquire the application file of a target application, determine the distribution information of instructions in a preset accelerated instruction set within the application file, and determine the dynamic processing information of the instructions in the preset accelerated instruction set during the execution of the target application. Based on the distribution information and the dynamic processing information, the usage of the preset accelerated instruction set by the target application is evaluated. This allows for comprehensive utilization of both the distribution information of instructions in the preset accelerated instruction set within the application file and the dynamic processing information of the instructions in the preset accelerated instruction set during the execution of the target application. The evaluation is more comprehensive and systematic, and eliminates the need for significant manual time and effort in checking or debugging assembly code. Therefore, it greatly improves the efficiency of evaluating the usage of accelerated instruction sets and effectively enhances the evaluation results. Attached Figure Description

[0033] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the 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.

[0034] Figure 1 A flowchart of a method for evaluating the usage of an accelerated instruction set provided for embodiments of the present invention; Figure 2 This is a flowchart illustrating the evaluation of acceleration instruction set usage during the execution of a target application, as described in an embodiment of the present invention. Figure 3 A detailed flowchart of a method for evaluating the usage of an accelerated instruction set provided for embodiments of the present invention; Figure 4 A schematic diagram of a device for evaluating the use of an accelerated instruction set provided in an embodiment of the present invention; Figure 5 A schematic diagram of an electronic device provided as an embodiment of the present invention. Detailed Implementation

[0035] The embodiments of the present invention will now be described in detail with reference to the accompanying drawings.

[0036] It should be understood that the described embodiments are merely some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.

[0037] In a first aspect, embodiments of the present invention provide a method for evaluating the use of accelerated instruction sets, which can greatly improve the evaluation efficiency of accelerated instruction set usage and effectively improve the evaluation results.

[0038] like Figure 1 As shown, an embodiment of the present invention provides a method for evaluating the usage of an accelerated instruction set, which may include: S11, Obtain the application file of the target application, wherein the application file includes source code file and / or binary file; In embodiments of the present invention, the target application is the application whose usage of acceleration instruction sets needs to be evaluated. The target application can include various types of applications and can run on one or more platforms. During the writing and compilation of the target application, corresponding instruction sets are used, some of which can accelerate software execution; these instruction sets can be referred to as acceleration instruction sets. Embodiments of the present invention are not limited to the architecture of the instruction sets; they can include x86 architecture instruction sets or other non-x86 architecture instruction sets. There can be multiple types of acceleration instruction sets, and each acceleration instruction set can include multiple acceleration instructions. Different acceleration instruction sets may have different specific application scenarios.

[0039] The application files of the target application may include the source code files and / or the binary files of the target application. The binary files, also known as executable files, can be obtained by compiling the source code files.

[0040] S12, determine the distribution information of instructions in the preset acceleration instruction set in the application file and determine the dynamic processing information of instructions in the preset acceleration instruction set during the operation of the target application. Preset acceleration instruction sets can refer to one or more pre-specified instruction sets that can speed up software execution, such as the SIMD instruction set.

[0041] In this step, on the one hand, it can detect whether the target application's application file contains instructions from a preset acceleration instruction set. If so, it can determine how these instructions from the preset acceleration instruction set are distributed within the application file, thus obtaining distribution information. On the other hand, it can also detect whether the target application dynamically processes instructions from the preset acceleration instruction set during its operation. If so, it can determine what specific dynamic processing is performed, thus obtaining dynamic processing information.

[0042] S13, Evaluate the target application's use of the preset acceleration instruction set based on the distribution information and the dynamic processing information.

[0043] In the embodiments of the present invention, distribution information and dynamic processing information can reflect the use of the preset acceleration instruction set by the target application from different levels. Based on this, by combining distribution information and dynamic processing information, the two types of information can be mutually verified and complemented, thereby providing a more comprehensive and accurate assessment of the use of the preset acceleration instruction set by the target application.

[0044] The method for evaluating the usage of accelerated instruction sets provided by embodiments of the present invention can acquire the application file of a target application, determine the distribution information of instructions in a preset accelerated instruction set within the application file, and determine the dynamic processing information of the instructions in the preset accelerated instruction set during the execution of the target application. Based on the distribution information and the dynamic processing information, the method evaluates the target application's usage of the preset accelerated instruction set. This allows for comprehensive utilization of both the distribution information of instructions in the preset accelerated instruction set within the application file and the dynamic processing information of the instructions in the preset accelerated instruction set during the execution of the target application to evaluate the target application's usage of the preset accelerated instruction set. The evaluation is more comprehensive and systematic, and eliminates the need for significant manual time and effort in checking or debugging assembly code. Therefore, it greatly improves the efficiency of evaluating the usage of accelerated instruction sets and effectively enhances the evaluation results.

[0045] Specifically, in one embodiment of the present invention, step S11 may obtain the application file of the target application. This application file may include the source code file of the target application, the binary file of the target application, or both; the embodiments of the present invention do not limit this. Depending on the type of application file, the specific method for determining the distribution information of instructions in the preset acceleration instruction set within the application file in step S12 may also vary. Here, the distribution information may include one or more of the following: the instruction type to which the instructions in the preset acceleration instruction set belong, the position of the instructions in the preset acceleration instruction set within the application file, and the number of times the instructions in the preset acceleration instruction set appear in the application file.

[0046] The following provides a detailed explanation of whether the application files include source code files or binary files.

[0047] First, let's explain the case where application files include source code files.

[0048] In one implementation, the application file of the target application may include a source code file; the distribution information may include first distribution information of instructions in a preset acceleration instruction set in the source code file. Based on this, determining the distribution information of instructions in the preset acceleration instruction set in the application file in step S12 may specifically include: determining whether the source code file contains a first target of interest according to a preset matching rule, the first target of interest including at least one of the following: preset compilation flags, preset inline functions, preset function libraries; if the source code file contains the first target of interest, searching for acceleration instructions associated with the first target of interest in the source code file to obtain the first acceleration instructions; and statistically analyzing the distribution of the first acceleration instructions in the source code file to obtain the first distribution information.

[0049] The preset matching rules can be constructed in various ways, such as based on keywords or regular expressions. Based on these preset matching rules, it can be determined whether the source code file contains a primary target of interest. The primary target of interest can include one or more of the following: preset compilation flags, preset inline functions, and preset function libraries.

[0050] Specifically, compiler flags can exist in the compiler configuration file within the source code file, used to instruct the compiler to use specified acceleration instruction sets. For example, the first focus target -march=native or -march=znver1 can instruct the compiler to optimize for the current or specified processor architecture, potentially automatically enabling relevant instruction sets. -mavx, -mavx2, -msse, -msse2, etc., can instruct the compiler to enable specific SIMD instruction sets. -mpclmul, -maes, etc., can instruct the compiler to enable cryptographic instructions (such as PCLMULQDQ, AES-NI). -mbmi, -mbmi2, etc., can instruct the compiler to enable bit manipulation instructions.

[0051] Inline functions are functions used to improve program efficiency. The basic idea is to replace function calls with function bodies during the compilation phase, thus eliminating the time and space overhead of function calls. Many compilers (such as GCC and Clang) provide a series of inline functions that allow developers to directly use accelerated instruction sets in C / C++ code without writing assembly code. Examples of inline functions include _mm_add_ps (SSE), _mm256_add_ps (AVX), and _mm_aesenc_si128 (AES-NI). The use of these inline functions can be identified by performing keyword searches, regular expression matching, or AST (Abstract Syntax Tree) analysis on the source code.

[0052] The default function library can refer to a third-party function library that is optimized for instruction set acceleration, such as the MKL library, the OpenBLAS library, etc. These function libraries may use SIMD or other acceleration instructions internally.

[0053] In embodiments of the present invention, after determining that the source code file contains a first target of interest, the source code file can be further searched for acceleration instructions associated with the first target of interest based on keywords, regular expressions, etc., to obtain the first acceleration instructions. For example, after determining that the source code file contains the compiler flag -mavx, the source code file can be further searched for whether there are instructions in the SIMD instruction set associated with the compiler flag -mavx to obtain the first acceleration instructions. Optionally, the number of first acceleration instructions can be one or more, wherein the position and frequency of each first acceleration instruction in the source code file are not limited. In one implementation, the distribution of the first acceleration instructions in the source code file can be statistically analyzed to obtain first distribution information.

[0054] The following section explains the case where application files include binary files.

[0055] In one implementation, the application file of the target application includes a binary file of the target application; the distribution information may include second distribution information of instructions in the preset acceleration instruction set in the binary file. Based on this, step S12, determining the distribution information of instructions in the preset acceleration instruction set in the application file, may specifically include: disassembling the binary file to obtain a disassembled code file of the target application; searching for instructions in the preset acceleration instruction set in the disassembled code file according to a preset matching rule to obtain second acceleration instructions; and statistically analyzing the distribution of the second acceleration instructions in the disassembled code file to obtain the second distribution information.

[0056] For example, in one instance, the objdump tool can be used to extract detailed disassembled code from a compiled binary file or dynamic library. The command format is: objdump -d<binary_file_or_dynamic_library> For example, executing `objdump -d my_application` or `objdump -d / usr / lib / mylib.so` can obtain the disassembled code of the application file.

[0057] The disassembled code file may include various disassembled instructions. In embodiments of the present invention, instructions in a preset acceleration instruction set can be searched in the disassembled code file according to preset matching rules to obtain a second acceleration instruction. For example, in one instance, the disassembled code file can be searched for instructions that match the following regular expression. For each such instruction found, a corresponding second acceleration instruction is obtained: AVX instruction mode: avx_pattern = r"\b(vaddps|vpmaddwd|vsubps|vfmadd231ps|vfnmadd231ps|vperm2f128ps|vpermi2ps|vzeroall|vzeromask|vBLENDVPD|vBLENDVPS|vBLENDVPS2)\b" AVX2 instruction mode: avx2_pattern = r"\b(vperm2i128|vpmovsdb|vpmovsdx|vpmovsdw|vpmovsqb|vpmovsqd|vpmovsqw|vpmovsxvd|vpmovsxwd|vpmovzxvd|vpmovzxwd|vpmovzxvd|vpmovz xwd|vBLENDVPS|vBLENDVPS2|vpternlogd|vpternlogq|vinsertf128|vextractf128|vinserti128|vextracti128|vinsertf32x8|vextractf32x8)\b" SSE series instruction modes: sse_pattern = r"\b(movaps|addps|subps|andps|orps|xorps|mulps|divps|sqrtss|rsqrtss|rcpss|andnpd|orpd|xorpd|addpd|subpd|mulpd|divpd|sqrtsd|rsqrtsd|rcsad|andnps|orps|xorps|addps|subps)\b" AES-NI instruction mode: aes_ni_pattern = r"\b(aesenc|aesenclast|aesdec|aesdeclast|aeskeygenassist|pclmulqdq)\b" BMI / BMI2 Command Mode: bmi_pattern = r"\b(andn|bextr|blsi|blsmsk|blsr|tzcnt|lzcnt|popcnt|mulx|bzhi|pdep|pext|rorx|sarx|shlx|shrx)\b" FMA instruction mode: fma_pattern = r"\b(vfmadd132ps|vfmadd213ps|vfmadd231ps|vfnmadd132ps|vfnmadd213ps|vfnmadd231ps)\b" Regular expressions can be used to efficiently match the x86 processor's supported acceleration instruction sets in disassembled code and perform corresponding statistical operations. For example, in one implementation, the number of instructions can be counted, such as the total number of various acceleration instruction sets contained in the binary file; in another implementation, the instruction type can be identified, such as identifying which specific instructions from each acceleration instruction set (AVX, AVX2, SSE, AES-NI, BMI, FMA) are used in the program; and in yet another implementation, the instruction location can be pinpointed, such as recording the offset of the acceleration instruction in the disassembled code, function name, etc., for further analysis.

[0058] The above provides a detailed explanation of how to determine the distribution information of instructions in the preset acceleration instruction set in the application file in step S12. However, the embodiments of the present invention are not limited thereto. The distribution information of instructions in the acceleration instruction set in the application file is a static information. In addition to determining the distribution information of instructions in the preset acceleration instruction set in the application file, in some embodiments of the present invention, step S12 can also determine the dynamic processing information of instructions in the preset acceleration instruction set during the operation of the target application.

[0059] Specifically, in one embodiment, determining the dynamic processing information of the instructions in the preset acceleration instruction set during the execution of the target application may include: detecting the dynamic link libraries loaded during the execution of the target application to obtain the target link library; disassembling the target link library to obtain the disassembled link library; searching for the instructions in the preset acceleration instruction set in the disassembled link library according to a preset matching rule to obtain the third acceleration instruction; and generating the dynamic processing information of the instructions in the preset acceleration instruction set during the execution of the target application based on the third acceleration instruction, wherein the dynamic processing information includes loading information.

[0060] In programming languages, a file containing a large number of functions (classes, methods) is called a library file. Library files enable code sharing. Depending on how they are used, library files can be divided into two types: static libraries (static library files or static libraries) and dynamic libraries (dynamic library files or dynamic libraries). Unlike static libraries, the executable file of a dynamic library typically only contains a table of the entry addresses of the functions it uses, rather than the entire machine code of the object file containing the external functions. Before the executable file starts running, the machine code of the external functions is copied from the dynamic library on the disk into memory by the operating system; this process is called dynamic linking. That is to say, when the target application is not running, the source code file and executable code file do not contain the actual content of the dynamic library. Only when the target application runs is the actual content of the dynamic library loaded into memory, allowing the instructions in the dynamic library to be examined.

[0061] Specifically, in one implementation, dynamic analysis techniques can be used to monitor the dynamic libraries loaded at runtime by the target application. For example, in one instance, the loading and unloading of dynamic link libraries can be monitored using the following command.

[0062] .. / .. / .. / <DBI analysis-framework> -t obj-intel64 / imageload.so -- / bin / ls Imageload.so can be used to report dynamic libraries loaded and unloaded by the program. -- This is followed by the target executable file and its parameters, such as / bin / ls.

[0063] Based on the above command, the following output can be obtained: Loading / bin / ls Loading / lib / ld-linux.so.2 Loading / lib / libtermcap.so.2 Loading / lib / i686 / libc.so.6 Unloading / bin / ls Unloading / lib / ld-linux.so.2 Unloading / lib / libtermcap.so.2 Unloading / lib / i686 / libc.so.6 The above output indicates that when executing the command `Loading / bin / ls`, the three dynamic link libraries ` / lib / ld-linux.so.2`, ` / lib / libtermcap.so.2`, and ` / lib / i686 / libc.so.6` were loaded, and when executing the command `UnLoading / bin / ls`, the three dynamic link libraries ` / lib / ld-linux.so.2`, ` / lib / libtermcap.so.2`, and ` / lib / i686 / libc.so.6` were unloaded.

[0064] It should be noted that the dynamic link libraries listed by the above instructions are those that are directly loaded and unloaded when executing Loading / bin / ls and Unloading / bin / ls. However, the embodiments of the present invention are not limited to this. In other embodiments of the present invention, it is possible to further detect whether each directly loaded dynamic link library depends on other dynamic link libraries. If it depends on other dynamic link libraries, these dependent dynamic link libraries can also be found.

[0065] Specifically, in one implementation, detecting the dynamic link libraries loaded during the execution of the target application to obtain the target link library may include: obtaining the dynamic link libraries directly called during the execution of the target application through a preset instruction, and adding the dynamic link libraries to a dynamic library queue; sequentially detecting whether each dynamic link library in the dynamic library queue has dependent dynamic link libraries in a first-in-first-out (FIFO) order; in response to any dynamic link library having dependent dynamic link libraries, adding the dependent dynamic link libraries to the dynamic library queue; jumping back to the step of sequentially detecting whether each dynamic link library in the dynamic library queue has dependent dynamic link libraries in a FIFO order and continuing to execute, iterating in a loop until all dynamic link libraries in the dynamic library queue have been detected; and using all the detected dynamic link libraries as the target link library.

[0066] For example, by using preset instructions, we can obtain dynamic link libraries A, B, and C that are directly called during the execution of the target application. Then, we can store dynamic link libraries A, B, and C in a dynamic library queue. Further detection of dynamic link library A reveals that it depends on dynamic link library D, so dynamic link library D is also added to the dynamic library queue. Next, we check whether dynamic link library B depends on other dynamic link libraries, and so on. This hierarchical traversal method not only traverses the dynamic libraries directly called by the target application but also recursively traverses other dynamic libraries that these libraries depend on. All detected dynamic link libraries are used as target libraries, thus enabling a more comprehensive detection of the target application's instruction usage.

[0067] In one embodiment of the present invention, each target link library in the dynamic library queue can be disassembled to obtain a disassembled link library. Then, according to a preset matching rule, instructions from the preset acceleration instruction set are searched in the disassembled link library to obtain a third acceleration instruction. The specific disassembly method and the method for searching for instructions in the preset acceleration instruction set are similar to the method for disassembling a binary file and searching for instructions in the preset acceleration instruction set in the disassembled file, which have been described in detail above and will not be repeated here.

[0068] After identifying the third acceleration instruction, dynamic processing information of the instructions in the preset acceleration instruction set during the execution of the target application can be generated based on the third acceleration instruction. This dynamic processing information may include loading information. The loading information can be used to indicate which dynamic link library is loaded during the execution of the target application, and which instructions from the preset acceleration instruction set are loaded in that dynamic link library. This makes the detection of the acceleration instruction set more precise and more conducive to optimizing the target application.

[0069] Furthermore, in addition to detecting the loading status of the preset acceleration instruction set in the dynamic link library, some embodiments of the present invention can also check the execution status of the instructions in the preset acceleration instruction set.

[0070] Specifically, in one embodiment of the present invention, determining the dynamic processing information of instructions in the preset acceleration instruction set during the execution of the target application may include: determining the dynamic processing information of instructions in the preset acceleration instruction set during the execution of the target application based on runtime instruction monitoring technology. Here, runtime instruction monitoring technology can refer to technology that monitors the execution of instructions in the application during application runtime, such as dynamic binary instrumentation technology, virtual layer monitoring technology, etc.

[0071] In one embodiment, the runtime instruction monitoring technology includes dynamic binary instrumentation. Based on this, determining the dynamic processing information of instructions in the preset acceleration instruction set during the execution of the target application, based on the runtime instruction monitoring technology, specifically includes: inserting a first callback function and a second callback function into the target application based on the dynamic binary instrumentation technology; before each instruction of the target application is executed, calling the first callback function to detect whether the instruction is an instruction in the preset acceleration instruction set, and obtaining a detection result; after the target application finishes running, calling the second callback function to generate dynamic processing information of instructions in the preset acceleration instruction set during the execution of the target application based on the detection results of each instruction, wherein the dynamic processing information includes execution information.

[0072] Binary instrumentation technology allows developers to insert custom code during program runtime, thereby monitoring, analyzing, or modifying program behavior without recompiling. In embodiments of this invention, by calling a first callback function before each instruction is executed, it can be detected whether the instruction belongs to a preset acceleration instruction set, thus filtering and checking each instruction running in the target application. Furthermore, after the target application finishes running, a second callback function can be called to summarize the detection results of each instruction, generating dynamic processing information of the instructions in the preset acceleration instruction set during the target application's runtime. This dynamic processing information includes execution information. The execution information can be used to indicate which instructions in the preset acceleration instruction set were executed during the target application's runtime, thereby effectively eliminating the influence of acceleration instruction sets distributed in unexecuted paths.

[0073] In another implementation, runtime instruction monitoring technology may include virtualization layer monitoring technology. Based on this, determining the dynamic processing information of instructions in the preset acceleration instruction set during the execution of the target application based on runtime instruction monitoring technology may include: running the target application in a virtual machine environment; intercepting instruction execution or specific hardware events during the execution of the target application using a virtual machine monitor; analyzing the opcode of the current instruction during the interception phase, detecting whether the instruction is an instruction in the preset acceleration instruction set, and obtaining a detection result; generating dynamic processing information of instructions in the preset acceleration instruction set during the execution of the target application based on the detection results of each instruction, wherein the dynamic processing information includes execution information.

[0074] Furthermore, regardless of whether it is based on dynamic binary instrumentation technology or virtualization layer monitoring technology, there is a step of detecting whether the instruction is an instruction in the preset acceleration instruction set and obtaining the detection result. Specifically, in one embodiment of the present invention, detecting whether the instruction is an instruction in the preset acceleration instruction set and obtaining the detection result may specifically include: obtaining the opcode or disassembled text of the current instruction to obtain the disassembled instruction; determining whether the disassembled instruction matches the instruction in the preset acceleration instruction set according to a preset matching rule; in response to the disassembled instruction matching the instruction in the preset acceleration instruction set, determining that the current instruction is an instruction in the preset acceleration instruction set and recording the association information of the current instruction to obtain the detection result. The association information includes one or more of the following: the memory address of the current instruction, the program module to which the current instruction belongs, the function to which the current instruction belongs, the number of times the current instruction is executed, the execution frequency, the cumulative number of execution cycles, context information, and the time percentage in the execution of the target application.

[0075] For example, in one instance, the objdump tool can be used to obtain the opcode or disassembled text of the current instruction, thus obtaining the disassembled instruction. The disassembled instruction can then be determined to match the instruction in the preset acceleration instruction set using regular expression matching. If the disassembled instruction matches the instruction in the preset acceleration instruction set, the current instruction is determined to be an instruction in the preset acceleration instruction set, and the association information of the current instruction is recorded to obtain the detection result.

[0076] For example, the process of evaluating the use of the acceleration instruction set during the execution of the target application can be as follows: Figure 2 As shown.

[0077] In this embodiment, the accelerated instruction set is identified during the instruction execution phase after compilation. However, the embodiments of the present invention are not limited to this. In other embodiments of the present invention, some instructions may be just-in-time (JIT) compilation instructions, that is, the code is compiled into machine code during program runtime, rather than pre-compiling before program execution. Based on this, in some implementations, the JIT compilation process can be hooked by a hook function to capture and analyze the generated machine code during the machine code (i.e., binary code) generation phase, thereby completing the identification of the accelerated instruction set before instruction execution.

[0078] The foregoing embodiments have provided a detailed explanation of how to determine the distribution information of instructions in the preset acceleration instruction set within the application file and how to determine the dynamic processing information of the instructions in the preset acceleration instruction set during the execution of the target application in step S12. Furthermore, after obtaining the aforementioned distribution information and dynamic processing information, the usage of the preset acceleration instruction set by the target application can be evaluated in step S13 based on the distribution information and the dynamic processing information.

[0079] Specifically, in one embodiment of the present invention, evaluating the target application's use of the preset acceleration instruction set based on the distribution information and the dynamic processing information may include: integrating the distribution information and the dynamic processing information; generating a visual report on the target application's use of the preset acceleration instruction set based on the integration result, thereby combining the distribution information and the dynamic processing information to more comprehensively and accurately evaluate the target application's use of the acceleration instruction set.

[0080] In one implementation, integrating the distribution information with the dynamic processing information may specifically include: comparing the distribution information with the dynamic processing information; for any instruction in the preset acceleration instruction set, if the distribution information contains the instruction and the dynamic processing information does not contain the instruction, determining that the instruction is in an unexecuted code path; for any instruction in the preset acceleration instruction set, if the distribution information does not contain the instruction and the dynamic processing information contains the instruction, determining that the instruction is a runtime-generated instruction or a dynamically loaded instruction.

[0081] The aforementioned distribution information can reveal the acceleration instruction sets that may be included in the target application, and can identify all instructions generated at compile time, including code paths that may never be executed (e.g., dead code or code for infrequently used functions). The aforementioned dynamic processing information can reveal the acceleration instruction sets actually used by the target program under specific execution paths, can eliminate the influence of dead code, and capture runtime-generated or dynamically loaded acceleration instruction sets. Comparing the distribution information with the dynamic processing information allows for mutual verification and complementarity, thereby providing a more comprehensive, detailed, and accurate assessment of the target application's use of acceleration instruction sets.

[0082] Optionally, in another embodiment of the present invention, integrating the distribution information and the dynamic processing information may specifically include: inputting the distribution information and the dynamic processing information into a pre-trained machine learning model, predicting preset items through the machine learning model, and obtaining an integration result. For example, these preset items may include at least one of the following: usage patterns of instructions in the preset acceleration instruction set, potential optimization opportunities of the target application, compatibility between the target application and the preset acceleration instruction set, etc.

[0083] After integrating the distribution information and the dynamic processing information, a visualization report on the target application's usage of the preset acceleration instruction set can be generated based on the integration result. For example, in one instance, the visualization report may include: the distribution information, the dynamic processing information, a comparison result between the distribution information and the dynamic processing information, and hierarchical classification statistics. This information can be visually displayed through various charts.

[0084] Optionally, in one implementation, the hierarchical classification statistics may include the following: Accelerated instruction sets use overview information to statistically analyze the total number and percentage of different instruction sets (such as AVX, AVX2, SSE, AES-NI, BMI, FMA, etc.) in distribution information and dynamic processing information.

[0085] Module-level statistics can list which binary files (such as main programs, dynamic libraries, etc.) contain the acceleration instruction set, and can also report the usage frequency of the acceleration instruction set and the usage frequency of each instruction in the acceleration instruction set.

[0086] Function-level statistics can identify specific functions that use accelerated instruction sets, thus providing more convenient conditions for performance optimization of the target application.

[0087] Execution path statistics can show which acceleration instruction sets are frequently executed in a specified scenario.

[0088] The following detailed description of the method for evaluating the usage of the accelerated instruction set provided by the embodiments of the present invention will be carried out through a specific example.

[0089] like Figure 3 As shown, the method for evaluating the usage of the accelerated instruction set provided in the embodiments of the present invention may include: S301. Obtain the application file of the target application, which includes source code file and / or binary file; S302. Based on the preset matching rules, determine whether the source code file contains a first target of concern. The first target of concern includes at least one of the following: preset compilation flags, preset inline functions, and preset function libraries. S303. If the source code file contains the first target of interest, search for the acceleration instructions associated with the first target of interest in the source code file to obtain the first acceleration instructions; S304. Statistically analyze the distribution of the first acceleration instructions in the source code file to obtain the first distribution information.

[0090] S305. Disassemble the binary file to obtain the disassembled code file of the target application; S306. According to the preset matching rules, search for instructions in the preset acceleration instruction set in the disassembled code file to obtain the second acceleration instruction; S307. Statistically analyze the distribution of the second acceleration instructions in the disassembled code file to obtain the second distribution information.

[0091] S308. Obtain the dynamic link library directly called during the runtime of the target application through preset instructions, and put the dynamic link library into the dynamic library queue. S309. In the order of first-in-first-out, check whether each dynamic link library in the dynamic library queue has dependent dynamic link libraries. S310. In response to any dynamic link library having a dependent dynamic link library, add the dependent dynamic link library to the dynamic library queue. S311. Determine whether all dynamic link libraries in the dynamic library queue have been detected. If yes, proceed to step S312; otherwise, proceed to step S309. S312. Use all detected dynamic link libraries as target link libraries; S313. Disassemble each target library to obtain the disassembled library; S314. According to the preset matching rules, search for the instruction in the preset acceleration instruction set in the disassembled link library to obtain the third acceleration instruction; S315. Based on the third acceleration instruction, generate dynamic processing information of the instructions in the preset acceleration instruction set during the operation of the target application, wherein the dynamic processing information includes loading information.

[0092] S316. Based on dynamic binary instrumentation technology, insert a first callback function and a second callback function into the target application; S317. Before each instruction of the target application is executed, the first callback function is called to check whether the instruction is an instruction in the preset accelerated instruction set and to obtain the detection result. For example, in the first callback function, the opcode or disassembled text of the current instruction can be obtained to obtain the disassembled instruction; according to a preset matching rule, it can be determined whether the disassembled instruction matches the instruction in the preset acceleration instruction set; in response to the disassembled instruction matching the instruction in the preset acceleration instruction set, it can be determined that the current instruction is an instruction in the preset acceleration instruction set and the association information of the current instruction can be recorded to obtain the detection result, wherein the association information includes at least one of the following: the memory address of the current instruction, the program module to which the current instruction belongs, the function to which the current instruction belongs, the number of times the current instruction is executed, the execution frequency, the cumulative number of execution cycles, context information, and the time percentage in the execution of the target application, etc.

[0093] S318. After the target application finishes running, call the second callback function to generate dynamic processing information of the instructions in the preset acceleration instruction set during the running of the target application based on the detection results of each instruction. The dynamic processing information includes execution information.

[0094] S319. Integrate distributed information with dynamic processing information; S320. Generate a visual report on the target application's usage of the preset acceleration instruction set based on the integration results.

[0095] The method for evaluating the usage of accelerated instruction sets provided in the embodiments of the present invention, by combining static code analysis (including source code and binary file analysis) with dynamic link library loading and dynamic binary instrumentation tracing, achieves an automated, comprehensive, and refined evaluation of the usage of software accelerated instruction sets, thereby producing the following significant technical effects: First, comprehensive and accurate instruction usage evaluation is achieved: by integrating source code analysis (examining compiler flags, inline functions, and specific library calls), binary file disassembly analysis (using objdump and regular expressions to match instruction patterns such as AVX, AVX2, SSE, AES-NI, BMI, and FMA), and runtime instruction monitoring techniques such as dynamic binary instrumentation, the limitations of single analysis methods are overcome. This allows the evaluation results to not only reflect instructions generated at compile time but also to track instructions actually executed at runtime in real time, including those generated by the JIT compiler, thus providing a comprehensive and accurate view of the acceleration instruction set usage.

[0096] Secondly, it significantly improves the automation and granularity of analysis: Compared to traditional methods that rely on human experience and manual operation, the method for evaluating the usage of acceleration instruction sets provided by the embodiments of this invention achieves a high degree of automation. Through predefined regular expressions and runtime instruction monitoring technology, it can automatically identify, statistically analyze, and quantify the usage of various acceleration instruction sets. Simultaneously, the report can be detailed down to specific modules, functions, and even execution frequencies, greatly reducing the cost of manual intervention, improving the efficiency and accuracy of large-scale software project analysis, and providing developers with precise opportunities to locate and optimize performance bottlenecks.

[0097] Third, it effectively supports cross-architecture CPU migration and compatibility assessment: The method for assessing the usage of accelerated instruction sets provided in the embodiments of this invention can clearly identify the software's dependency on specific accelerated instruction sets (such as AVX, AVX2, SSE, AES-NI, etc.). This allows for the automatic assessment of migration difficulty, workload, and potential instruction set compatibility issues when migrating software from one x86 architecture CPU to other x86 architecture CPUs. This assists developers in making more accurate migration plans and diagnosing problems, avoiding runtime errors or performance degradation caused by instruction set incompatibility.

[0098] Fourth, this solution precisely quantifies performance bottlenecks and guides optimization: By statistically analyzing the number and execution frequency of different acceleration instruction sets at both static and dynamic levels, developers can clearly understand the actual utilization of hardware acceleration capabilities by their software. This helps to accurately determine whether performance bottlenecks stem from insufficient or improper use of acceleration instruction sets, or from a complete lack of utilization of hardware acceleration capabilities. This provides a quantitative basis and precise guidance for targeted performance tuning, significantly improving optimization efficiency and effectiveness.

[0099] Fifth, it assists in verifying compiler optimization effects: it can compare the results of static analysis (compiler output) and dynamic analysis (actual execution) to verify whether the compiler generates the accelerated instruction set as expected, and the impact of different compilation options on instruction generation and runtime utilization. This provides strong technical support for adjusting and verifying compiler optimization strategies, ensuring that the compilation toolchain can maximize hardware performance.

[0100] Secondly, embodiments of the present invention provide an evaluation apparatus for the use of accelerated instruction sets, which can greatly improve the evaluation efficiency of accelerated instruction set use and effectively improve the evaluation results.

[0101] like Figure 4 As shown, the acceleration instruction set usage evaluation apparatus provided in the embodiments of the present invention may include: Acquisition unit 41 is used to acquire the application file of the target application, wherein the application file includes source code file and / or binary file; The determining unit 42 is used to determine the distribution information of instructions in the preset acceleration instruction set in the application file and to determine the dynamic processing information of instructions in the preset acceleration instruction set during the operation of the target application. Evaluation unit 43 is used to evaluate the target application’s use of the preset acceleration instruction set based on the distribution information and the dynamic processing information.

[0102] The acceleration instruction set usage evaluation apparatus provided in the embodiments of the present invention can acquire the application file of a target application, determine the distribution information of instructions in a preset acceleration instruction set in the application file, and determine the dynamic processing information of the instructions in the preset acceleration instruction set during the operation of the target application. Based on the distribution information and the dynamic processing information, the apparatus evaluates the target application's usage of the preset acceleration instruction set. This allows for comprehensive utilization of both the distribution information of instructions in the preset acceleration instruction set within the application file and the dynamic processing information of the instructions in the preset acceleration instruction set during the operation of the target application to evaluate the target application's usage of the preset acceleration instruction set. The evaluation is more comprehensive and systematic, and eliminates the need for significant manual time and effort to inspect or debug assembly code. Therefore, it greatly improves the efficiency of acceleration instruction set usage evaluation and effectively enhances the evaluation results.

[0103] In one embodiment, the application file includes a source code file; the distribution information includes first distribution information of instructions in the preset acceleration instruction set in the source code file; the determining unit includes: a first determining module, configured to determine whether the source code file contains a first target of interest according to a preset matching rule, the first target of interest including at least one of the following: a preset compilation flag, a preset inline function, a preset function library; a first searching module, configured to search for acceleration instructions associated with the first target of interest in the source code file when the source code file contains the first target of interest, to obtain the first acceleration instructions; and a first statistics module, configured to perform statistics on the distribution of the first acceleration instructions in the source code file to obtain the first distribution information.

[0104] In one embodiment, the application file includes a binary file; the distribution information includes second distribution information of instructions in the preset acceleration instruction set within the binary file; the determining unit includes: a first disassembly module, configured to disassemble the binary file to obtain a disassembled code file of the target application; a second search module, configured to search for instructions in the preset acceleration instruction set within the disassembled code file according to preset matching rules to obtain second acceleration instructions; and a second statistics module, configured to statistically analyze the distribution of the second acceleration instructions within the disassembled code file to obtain the second distribution information.

[0105] In one embodiment, the determining unit includes: a first detection module, configured to detect dynamic link libraries loaded during the execution of the target application, and obtain a target link library; a second disassembly module, configured to disassemble the target link library, and obtain a disassembled link library; a third search module, configured to search for instructions in the disassembled link library according to preset matching rules, and obtain a third acceleration instruction; and a first generation module, configured to generate dynamic processing information of the instructions in the preset acceleration instruction set during the execution of the target application according to the third acceleration instruction, wherein the dynamic processing information includes loading information.

[0106] In one implementation, the first detection module is specifically configured to: obtain the dynamic link libraries directly called during the execution of the target application through a preset instruction, and add the dynamic link libraries to a dynamic library queue; sequentially detect whether each dynamic link library in the dynamic library queue has dependent dynamic link libraries in a first-in-first-out (FIFO) order; in response to any dynamic link library having dependent dynamic link libraries, add the dependent dynamic link libraries to the dynamic library queue; jump back to the step of sequentially detecting whether each dynamic link library in the dynamic library queue has dependent dynamic link libraries in a first-in-first-out (FIFO) order, and continue execution, iterating until all dynamic link libraries in the dynamic library queue have been detected; and use all the detected dynamic link libraries as the target link libraries.

[0107] In one implementation, the determining unit is specifically used to determine the dynamic processing information of the instructions in the preset acceleration instruction set during the operation of the target application based on runtime instruction monitoring technology.

[0108] In one implementation, the runtime instruction monitoring technology includes dynamic binary instrumentation; the determining unit includes: an insertion module, used to insert a first callback function and a second callback function into the target application based on the dynamic binary instrumentation; a first calling module, used to call the first callback function before the execution of each instruction in the target application, to detect whether the instruction is an instruction in the preset acceleration instruction set, and to obtain a detection result; a second calling module, used to call the second callback function after the target application finishes running, and to generate dynamic processing information of the instructions in the preset acceleration instruction set during the running of the target application based on the detection results of each instruction. The dynamic processing information includes execution information; or, the runtime instruction monitoring technology includes: virtualization layer monitoring technology; the determining unit includes: a running module, used to run the target application in a virtual machine environment; an interception module, used to intercept instruction execution or specific hardware events during the runtime of the target application using a virtual machine monitor; an analysis module, used to analyze the opcode of the current instruction during the interception phase, detect whether the instruction is an instruction in the preset acceleration instruction set, and obtain a detection result; a second generation module, used to generate dynamic processing information of the instructions in the preset acceleration instruction set during the runtime of the target application based on the detection results of each instruction, the dynamic processing information including execution information.

[0109] In one implementation, the first calling module or the analysis module is specifically configured to: obtain the opcode or disassembled text of the current instruction to obtain the disassembled instruction; determine whether the disassembled instruction matches an instruction in the preset acceleration instruction set according to a preset matching rule; in response to the disassembled instruction matching an instruction in the preset acceleration instruction set, determine that the current instruction is an instruction in the preset acceleration instruction set and record the association information of the current instruction to obtain the detection result, wherein the association information includes at least one of the following: the memory address of the current instruction, the program module to which the current instruction belongs, the function to which the current instruction belongs, the number of times the current instruction is executed, the execution frequency, the cumulative number of execution cycles, context information, and the time percentage in the execution of the target application.

[0110] In one implementation, the distribution information includes at least one of the following: the instruction type to which the instruction in the preset acceleration instruction set belongs, the position of the instruction in the preset acceleration instruction set in the application file, and the number of times the instruction in the preset acceleration instruction set appears in the application file.

[0111] In one embodiment, the evaluation unit includes: an integration module for integrating the distribution information with the dynamic processing information; and a second generation module for generating a visualization report on the target application's usage of the preset acceleration instruction set based on the integration result.

[0112] In one implementation, the integration module is specifically configured to: compare the distribution information with the dynamic processing information; for any instruction in the preset acceleration instruction set, if the distribution information contains the instruction and the dynamic processing information does not contain the instruction, determine that the instruction is in an unexecuted code path; for any instruction in the preset acceleration instruction set, if the distribution information does not contain the instruction and the dynamic processing information contains the instruction, determine that the instruction is a runtime-generated instruction or a dynamically loaded instruction.

[0113] In one implementation, the visualization report includes: the distribution information, the dynamic processing information, a comparison result between the distribution information and the dynamic processing information, and hierarchical classification statistics.

[0114] In one implementation, the integration module is specifically used to: input the distribution information and the dynamic processing information into a pre-trained machine learning model, and predict preset items through the machine learning model. The preset items include at least one of the following: the usage pattern of instructions in the preset acceleration instruction set, the potential optimization opportunities of the target application, and the compatibility between the target application and the preset acceleration instruction set.

[0115] Thirdly, embodiments of the present invention also provide an electronic device that can effectively improve the timing convergence speed of a circuit.

[0116] like Figure 5 As shown, the electronic device provided in the embodiments of the present invention may include: a processor 71 and a memory 72, wherein the processor 71 and the memory 72 are electrically connected; the memory 72 is used to store executable program code; the processor 71 runs a program corresponding to the executable program code by reading the executable program code stored in the memory 72, so as to implement any of the acceleration instruction set usage evaluation methods provided in the foregoing embodiments.

[0117] The specific execution process of the above steps by the processor 71, as well as the steps further executed by the processor 71 by running executable program code, can be found in the description of the foregoing embodiments, and will not be repeated here.

[0118] Fourthly, embodiments of the present invention also provide a computer-readable storage medium storing one or more programs that can be executed by one or more processors to implement any of the acceleration instruction set usage evaluation methods provided in the foregoing embodiments, thus achieving the corresponding technical effects. This has been described in detail above and will not be repeated here.

[0119] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0120] The various embodiments in this specification are described in a related manner. The same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on describing the differences from other embodiments.

[0121] In particular, the device embodiment is basically similar to the method embodiment, so the description is relatively simple. For relevant details, please refer to the description of the method embodiment.

[0122] For ease of description, the above apparatus is described by dividing it into various functional units / modules. Of course, in implementing this invention, the functions of each unit / module can be implemented in one or more software and / or hardware.

[0123] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.

[0124] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. A method for evaluating the usage of an accelerated instruction set, characterized in that, include: Obtain the application files of the target application, including source code files and / or binary files; Determine the distribution information of instructions in the preset acceleration instruction set in the application file and determine the dynamic processing information of instructions in the preset acceleration instruction set during the operation of the target application; The target application's use of the preset acceleration instruction set is evaluated based on the distribution information and the dynamic processing information.

2. The method for evaluating the usage of the accelerated instruction set according to claim 1, characterized in that, The application file includes a source code file; the distribution information includes the first distribution information of the instructions in the preset acceleration instruction set in the source code file; The information on the distribution of instructions in the preset acceleration instruction set within the application file includes: According to preset matching rules, it is determined whether the source code file contains a first target of interest, the first target of interest including at least one of the following: preset compilation flags, preset inline functions, and preset function libraries; If the source code file contains the first target of interest, the acceleration instructions associated with the first target of interest are searched in the source code file to obtain the first acceleration instructions; The distribution of the first acceleration instructions in the source code file is statistically analyzed to obtain the first distribution information.

3. The method for evaluating the usage of the accelerated instruction set according to claim 1, characterized in that, The application file includes a binary file; the distribution information includes the second distribution information of the instructions in the preset acceleration instruction set within the binary file; The information on the distribution of instructions in the preset acceleration instruction set within the application file includes: The binary file is disassembled to obtain the disassembled code file of the target application; According to the preset matching rules, the instructions in the preset acceleration instruction set are searched in the disassembled code file to obtain the second acceleration instruction; The distribution of the second acceleration instructions in the disassembled code file is statistically analyzed to obtain the second distribution information.

4. The method for evaluating the usage of the accelerated instruction set according to claim 1, characterized in that, The determination of the dynamic processing information of the instructions in the preset acceleration instruction set during the execution of the target application includes: The target library is obtained by detecting the dynamic link libraries loaded during the execution of the target application. The target library is disassembled to obtain a disassembled library; According to the preset matching rules, the instructions in the preset acceleration instruction set are searched in the disassembled link library to obtain the third acceleration instruction; Based on the third acceleration instruction, dynamic processing information of the instructions in the preset acceleration instruction set during the operation of the target application is generated, and the dynamic processing information includes loading information.

5. The method for evaluating the usage of the accelerated instruction set according to claim 4, characterized in that, The detection of dynamic link libraries loaded during the execution of the target application, and the acquisition of the target link libraries, include: The dynamic link library directly called during the operation of the target application is obtained by a preset instruction, and the dynamic link library is added to the dynamic library queue. Following a first-in, first-out (FIFO) order, each dynamic link library in the dynamic library queue is sequentially checked to see if it has dependent dynamic link libraries. In response to any of the dynamic link libraries having dependent dynamic link libraries, the dependent dynamic link libraries are added to the dynamic library queue. Jump to the step of checking whether each dynamic link library in the dynamic library queue has dependent dynamic link libraries in the first-in-first-out order and continue to execute, looping and iterating until all dynamic link libraries in the dynamic library queue have been checked. All the detected dynamic link libraries are used as the target link libraries.

6. The method for evaluating the usage of the accelerated instruction set according to claim 1, characterized in that, The determination of the dynamic processing information of the instructions in the preset acceleration instruction set during the execution of the target application includes: Based on runtime instruction monitoring technology, the dynamic processing information of instructions in the preset acceleration instruction set during the execution of the target application is determined.

7. The method for evaluating the usage of the accelerated instruction set according to claim 6, characterized in that, The runtime instruction monitoring technology includes: dynamic binary instrumentation technology; The method of determining the dynamic processing information of instructions in the preset acceleration instruction set during the execution of the target application based on runtime instruction monitoring technology includes: Based on the dynamic binary instrumentation technology, a first callback function and a second callback function are inserted into the target application; Before each instruction of the target application is executed, the first callback function is called to detect whether the instruction is an instruction in the preset acceleration instruction set and to obtain the detection result. After the target application finishes running, the second callback function is invoked to generate dynamic processing information of the instructions in the preset acceleration instruction set during the running of the target application based on the detection results of each instruction. The dynamic processing information includes execution information.

8. The method for evaluating the usage of the accelerated instruction set according to claim 6, characterized in that, The runtime instruction monitoring technology includes: virtualization layer monitoring technology; The method of determining the dynamic processing information of instructions in the preset acceleration instruction set during the execution of the target application based on runtime instruction monitoring technology includes: Run the target application in a virtual machine environment; The virtual machine monitor is used to intercept the execution of instructions or specific hardware events during the runtime of the target application. During the interception phase, the opcode of the current instruction is analyzed to detect whether the instruction is an instruction in the preset acceleration instruction set, and the detection result is obtained. Based on the detection results of each instruction, dynamic processing information of the instructions in the preset acceleration instruction set during the operation of the target application is generated, and the dynamic processing information includes execution information.

9. The method for evaluating the usage of the accelerated instruction set according to claim 7 or 8, characterized in that, The detection of whether the instruction belongs to the preset acceleration instruction set, and the resulting detection result, include: Obtain the opcode or disassembled text of the current instruction to get the disassembled instruction; According to the preset matching rules, it is determined whether the disassembly instructions match the instructions in the preset acceleration instruction set; In response to the disassembly instruction matching the instruction in the preset acceleration instruction set, the current instruction is determined to be an instruction in the preset acceleration instruction set, and the association information of the current instruction is recorded to obtain the detection result. The association information includes at least one of the following: the memory address of the current instruction, the program module to which the current instruction belongs, the function to which the current instruction belongs, the number of times the current instruction is executed, the execution frequency, the cumulative number of execution cycles, the context information, and the time percentage in the execution of the target application.

10. The method for evaluating the usage of the accelerated instruction set according to claim 1, characterized in that, The distribution information includes at least one of the following: the instruction type to which the instruction in the preset acceleration instruction set belongs, the position of the instruction in the preset acceleration instruction set in the application file, and the number of times the instruction in the preset acceleration instruction set appears in the application file.

11. The method for evaluating the usage of accelerated instruction sets according to any one of claims 1 to 8, characterized in that, The step of evaluating the target application's use of the preset acceleration instruction set based on the distribution information and the dynamic processing information includes: Integrate the distribution information with the dynamic processing information; Based on the integration results, a visual report is generated showing how the target application uses the preset acceleration instruction set.

12. The method for evaluating the usage of the accelerated instruction set according to claim 11, characterized in that, The integration of the distribution information with the dynamic processing information includes: Compare the distribution information with the dynamic processing information; For any instruction in the preset acceleration instruction set, if the distribution information contains the instruction and the dynamic processing information does not contain the instruction, it is determined that the instruction is in an unexecuted code path; For any instruction in the preset acceleration instruction set, if the distribution information does not contain the instruction but the dynamic processing information does contain the instruction, the instruction is determined to be a runtime-generated instruction or a dynamically loaded instruction.

13. The method for evaluating the usage of the accelerated instruction set according to claim 11, characterized in that, The visualization report includes: the distribution information, the dynamic processing information, the comparison results between the distribution information and the dynamic processing information, and hierarchical classification statistics.

14. An apparatus for evaluating the usage of an accelerated instruction set, characterized in that, include: The acquisition unit is used to acquire the application file of the target application, wherein the application file includes source code file and / or binary file; The determining unit is used to determine the distribution information of instructions in the preset acceleration instruction set in the application file and to determine the dynamic processing information of the instructions in the preset acceleration instruction set during the operation of the target application. An evaluation unit is used to evaluate the target application's use of the preset acceleration instruction set based on the distribution information and the dynamic processing information.

15. An electronic device, characterized in that, The electronic device includes: a processor and a memory, wherein the processor is electrically connected to the memory; the memory is used to store executable program code; the processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, so as to implement the method for evaluating the use of the acceleration instruction set as described in any one of claims 1 to 13.

16. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores one or more programs that can be executed by one or more processors to implement the method for evaluating the use of the accelerated instruction set as described in any one of claims 1 to 13.

Citation Information

Patent Citations

  • Method and apparatus for determining refined context for software vulnerability detection and correction

    CN116266229A

  • Information processing method, device and equipment

    CN116932045A

  • RISC-V instruction acceleration operation method and device, electronic equipment and storage medium

    CN118502822A

  • Technique for detecting executable malicious code using a combination of static and dynamic analyses

    US20050108562A1

  • Unifying static and dynamic compiler optimizations in source-code bases

    US20140082597A1