Search

CN-122019343-A - Program runtime checking method, storage medium, and program product

CN122019343ACN 122019343 ACN122019343 ACN 122019343ACN-122019343-A

Abstract

The application provides a program runtime inspection method, a storage medium, and a program product. The program run-time checking method comprises the steps of loading equipment side target codes, performing instrumentation operation on the equipment side target codes to obtain equipment side target codes after instrumentation, sending the equipment side target codes after instrumentation to the equipment side for execution, obtaining instruction data stored by the equipment side in the execution process, and performing simulation on the instruction data through a parallel simulator to check the program run of the equipment side target codes. According to the method, the target code of the equipment side after the pile is inserted is sent to the equipment side for execution, when the equipment side executes the target instruction, the instruction data in the execution process of the target instruction can be recorded, the host side carries out simulation on the instruction data through the parallel simulator, the running overhead caused by the running inspection of the program by the equipment side can be reduced, and the problem that the program of the equipment side is crashed due to the overlong processing time of the equipment side is avoided.

Inventors

  • Request for anonymity
  • Request for anonymity

Assignees

  • 寒武纪(昆山)信息科技有限公司

Dates

Publication Date
20260512
Application Date
20241111

Claims (18)

  1. 1. A program runtime inspection method, the method comprising: Loading a device side target code, and performing instrumentation operation on the device side target code to obtain an instrumented device side target code; Transmitting the target code of the equipment side after the pile insertion to the equipment side for execution, and acquiring instruction data stored by the equipment side in the execution process; and performing simulation on the instruction data through a parallel simulator so as to check the program running of the equipment side target code.
  2. 2. The method according to claim 1, wherein the method further comprises: and maintaining a device side memory, wherein the device side memory is used for storing the instruction data.
  3. 3. The method of claim 2, wherein the instruction data comprises a physical core identifier of the executing instruction, a logical task identifier of the executing instruction, an opcode of the instruction, a core unique identifier of the instruction, an offset of the instruction in an instruction segment of the function in which the instruction is located, and a hash value of the function in which the instruction is located.
  4. 4. The method of claim 2, wherein the method further comprises, prior to the sending the instrumented device-side object code to the device-side for execution: and creating a context for the instrumented device-side target code, wherein the context is used for providing an execution environment for the instrumented device-side target code.
  5. 5. The method of claim 4, wherein maintaining the device-side memory specifically comprises: And when a context is created for the instrumented device side object code, device side memory allocation is performed.
  6. 6. A method according to claim 3, wherein said obtaining instruction data stored by the device side during execution comprises: and copying the data stored in the equipment side memory to obtain the instruction data.
  7. 7. The method according to claim 1, wherein the obtaining instruction data stored on the device side during execution specifically includes: according to the set interval time length, periodically performing data refreshing operation to acquire the instruction data; Or alternatively And after the synchronous interface is called, carrying out data refreshing operation to acquire the instruction data.
  8. 8. The method according to claim 4, wherein the method further comprises: After the execution of the device side object code after the instrumentation is completed on the device side, destroying the context corresponding to the device side object code after the instrumentation; and releasing the device-side memory corresponding to the context associated with the device-side target code after the instrumentation; the obtaining the instruction data stored in the execution process by the equipment side specifically includes: and when the context corresponding to the device side target code after the instrumentation is destroyed, acquiring the instruction data.
  9. 9. The method of claim 1, wherein the performing, by a parallel simulator, the emulation simulation of the instruction data to check program execution of the device-side target code, further comprises: Before and after the simulation, the parallel simulator calls an inspection tool to inspect the state of the equipment side memory corresponding to the equipment side object code.
  10. 10. The method according to claim 9, wherein the method further comprises: performing inspection tool registration to establish call rights of the parallel simulator to the inspection tool.
  11. 11. The method according to claim 10, wherein the method further comprises: Hijacking a runtime application programming interface to obtain runtime data of a device side, wherein the runtime application programming interface comprises at least one of an initialization operation interface, a resource creation interface, a resource destruction interface, a memory operation interface, a module loading interface and a synchronization interface; the step of performing simulation on the instruction data by a parallel simulator to check the program operation of the equipment side target code specifically includes: And performing simulation on the instruction data and the equipment side runtime data through the parallel simulator, and checking the program running of the equipment side target code.
  12. 12. The method of claim 1, wherein loading device side target code comprises: Obtaining a device side code through hijacking a module object loading interface, and obtaining a hardware instruction in the device side code; And if the hardware instruction is a target instruction, taking the equipment side code as the equipment side target code.
  13. 13. The method of claim 1, wherein the instrumentation of the device-side object code to obtain an instrumented device-side object code comprises: Inserting a instrumentation function corresponding to the target instruction into the target instruction to generate an equipment side target code after instrumentation.
  14. 14. The method of claim 13, wherein the method further comprises: The method comprises the steps of obtaining an instruction description file, wherein the instruction description file is used for describing information of a hardware instruction; Generating a first intermediate file according to the instruction description file; And generating a instrumentation function corresponding to the hardware instruction according to the first intermediate file, wherein the instrumentation function comprises an instrumentation logic header file of a host side, an instrumentation function header file of a device side and an instruction information header file.
  15. 15. The method according to any one of claims 1 to 14, wherein after performing emulation simulation of the instruction data by a parallel simulator to check program execution of the device-side target code, the method further comprises: If the error instruction with the error exists in the equipment side target code, mapping the error instruction back to the position of the source code corresponding to the equipment side target code.
  16. 16. The method of claim 15, wherein mapping the error instruction back to the location of the source code corresponding to the device side object code, specifically comprises: acquiring instruction data corresponding to the error instruction; According to the instruction data, obtaining the offset of the error instruction in the function instruction section, the hash value of the function where the instruction is located and the kernel unique identifier of the instruction; Calculating to obtain the value of a program counter according to the offset of the error instruction in the instruction section of the function, the hash value of the function in which the instruction is located and the unique identifier of the kernel of the instruction; And acquiring the position of the source code corresponding to the error instruction from the debugging information data segment of the equipment side target code according to the value of the program counter.
  17. 17. A computer readable storage medium having stored therein computer executable instructions which when executed by a processor are adapted to carry out the method of any one of claims 1 to 16.
  18. 18. A computer program product comprising a computer program which, when executed by a processor, implements the method of any one of claims 1 to 16.

Description

Program runtime checking method, storage medium, and program product Technical Field The present application relates to computer software technology, and more particularly, to a program runtime inspection method, a storage medium, and a program product. Background Various errors may occur in the running process of the program, and a developer usually uses a dynamic binary instrumentation technology to check and repair potential problems such as memory access errors, multi-thread contention access and the like of the target program so as to improve the stability and reliability of the program. Dynamic binary instrumentation techniques may insert specific instructions or code without the need for source code to enable monitoring or modification of program behavior. Dynamic binary instrumentation is typically applied to central processing unit (Central Processing Unit, CPU) or graphics processing unit (Graphics Processing Unit, GPU) programs, often used in the scenarios of performance analysis, debugging, etc. of the programs. Whereas programming for a neural processing unit (Neural Processing Unit, NPU) is typically vector operation of a large block of memory, e.g., an instruction may perform large-scale memory operations, e.g., memory operations may be tens of kilobytes (Kilobyte, KB) of data. If the run-time checking device puts these large-batch data updating operations on the device side for processing, the processing time on the device side is too long, and the watchdog timer is triggered, so that the system considers that the program is suspended, and the device side program is crashed. Disclosure of Invention The application provides a program runtime checking method, a storage medium and a program product, which are used for solving the problem that the existing program runtime error checking method is easy to cause the program on the equipment side to crash. Loading equipment side target codes, and performing instrumentation operation on the equipment side target codes to obtain instrumented equipment side target codes; Transmitting the target code of the equipment side after the pile insertion to the equipment side for execution, and acquiring instruction data stored by the equipment side in the execution process; and performing simulation on the instruction data through a parallel simulator so as to check the program running of the equipment side target code. Optionally, the method further comprises maintaining a device side memory, wherein the device side memory is used for storing the instruction data. Optionally, the instruction data comprises a physical core identifier of an executing instruction, a logical task identifier of the executing instruction, an operation code of the instruction, a kernel unique identifier of the instruction, an offset of the instruction in an instruction segment of the function, and a hash value of the function in which the instruction is located. Optionally, before the step of sending the instrumented device side target code to the device side for execution, the method further includes: and creating a context for the instrumented device-side target code, wherein the context is used for providing an execution environment for the instrumented device-side target code. Optionally, the maintaining the device-side memory specifically includes: And when a context is created for the instrumented device side object code, device side memory allocation is performed. Optionally, the acquiring instruction data stored by the device side in an execution process includes: and copying the data stored in the equipment side memory to obtain the instruction data. Optionally, the acquiring instruction data stored on the device side in the executing process specifically includes: according to the set interval time length, periodically performing data refreshing operation to acquire the instruction data; or after the synchronous interface is called, carrying out data refreshing operation to acquire the instruction data. Optionally, the method further comprises: After the execution of the device side object code after the instrumentation is completed on the device side, destroying the context corresponding to the device side object code after the instrumentation; and releasing the device-side memory corresponding to the context associated with the device-side target code after the instrumentation; the obtaining the instruction data stored in the execution process by the equipment side specifically includes: and when the context corresponding to the device side target code after the instrumentation is destroyed, acquiring the instruction data. Optionally, the performing, by a parallel simulator, simulation on the instruction data to check program running of the device side target code further includes: Before and after the simulation, the parallel simulator calls an inspection tool to inspect the state of the equipment side memory corresponding to the equipment side object code. Optionally,