WO2021047585A1 - 程序调试方法、装置、调试工具和计算机设备 - Google Patents

程序调试方法、装置、调试工具和计算机设备 Download PDF

Info

Publication number
WO2021047585A1
WO2021047585A1 PCT/CN2020/114486 CN2020114486W WO2021047585A1 WO 2021047585 A1 WO2021047585 A1 WO 2021047585A1 CN 2020114486 W CN2020114486 W CN 2020114486W WO 2021047585 A1 WO2021047585 A1 WO 2021047585A1
Authority
WO
WIPO (PCT)
Prior art keywords
executable program
variable value
checkpoint
debugging
program
Prior art date
Application number
PCT/CN2020/114486
Other languages
English (en)
French (fr)
Inventor
孟小甫
江广
陈峋宇
孙咏哲
Original Assignee
安徽寒武纪信息科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 安徽寒武纪信息科技有限公司 filed Critical 安徽寒武纪信息科技有限公司
Publication of WO2021047585A1 publication Critical patent/WO2021047585A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3624Software debugging by performing operations on the source code, e.g. via a compiler
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3644Software debugging by instrumenting at runtime
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation

Definitions

  • This application relates to the field of computer technology, and in particular to a program debugging method, device, debugging tool, and computer equipment.
  • the embodiments of the application provide a program debugging method, device, debugging tool, computer equipment, and storage medium, which can execute two executable programs generated by different processors simultaneously through a preset debugging tool, and then correspond to the artificial intelligence processor.
  • the executable program is debugged.
  • an embodiment of the present application provides a program debugging method, which includes:
  • first executable program and a second executable program where the first executable program and the second executable program are programs compiled by the code to be debugged.
  • an embodiment of the present application provides a program debugging device, which may include:
  • An obtaining unit configured to obtain a first executable program and a second executable program, where the first executable program and the second executable program are programs compiled by the code to be debugged;
  • the debugging unit is configured to debug the first executable program and the second executable program based on a first debugging operation for the first executable program or the second executable program.
  • an embodiment of the present application provides a computer device, including a processor and a memory, the processor and the memory are connected to each other, wherein the processor includes a general-purpose processor and an artificial intelligence processor, and the memory is used for A computer program that supports a computer device to execute the above method is stored, the computer program includes program instructions, and the processor is configured to invoke the program instructions to execute the method of the above first aspect.
  • an embodiment of the present application provides a computer-readable storage medium that stores a computer program, and the computer program includes program instructions that, when executed by a processor, cause the processing The device executes the method of the first aspect described above.
  • an embodiment of the present application provides a computer program.
  • the computer program includes program instructions that, when executed by a processor, cause the processor to execute the method of the first aspect.
  • the embodiment of the present application also provides a debugging tool, the debugging tool is used to perform the following steps:
  • the first executable program and the second executable program are debugged.
  • FIG. 1 is a schematic structural diagram of a computer device provided by an embodiment of the present application.
  • FIG. 2A is a schematic flowchart of a program debugging method provided by an embodiment of the present application
  • 2B is a schematic flowchart of steps for debugging the first executable program and the second executable program based on a first debugging operation according to an embodiment of the present application;
  • 2C is a schematic flowchart of steps for obtaining at least one first variable value in a first executable program and at least one second variable value in a second executable program according to an embodiment of the present application;
  • 2D is a schematic flowchart of another step of obtaining at least one first variable value in a first executable program and at least one second variable value in a second executable program according to an embodiment of the present application;
  • FIG. 2E is a schematic flowchart of steps for determining the running result of a second executable program according to at least one first variable value and at least one second variable value according to an embodiment of the present application;
  • FIG. 3 is a schematic flowchart of another program debugging method disclosed in an embodiment of the present application.
  • FIG. 4 is a schematic flowchart of another program debugging method disclosed in an embodiment of the present application.
  • Fig. 5 is a schematic structural diagram of a program debugging device provided by an embodiment of the present application.
  • the term “if” can be interpreted as “when” or “once” or “in response to determination” or “in response to detection” depending on the context.
  • the phrase “if determined” or “if detected [described condition or event]” can be interpreted as meaning “once determined” or “in response to determination” or “once detected [described condition or event]” depending on the context ]” or “in response to detection of [condition or event described]”.
  • low-precision data can bring huge benefits to the operating performance of the program and the power consumption generated by the calculation.
  • low-precision calculations can greatly increase the operating speed under the premise of small operating results.
  • the embodiments of the present application provide a program debugging method, which can realize the debugging of codes with different precisions in heterogeneous systems. Further, the program debugging method of the embodiment of the present application can also use the same debugging tool to implement simultaneous debugging of codes with different precisions, which avoids switching between debugging tools and is convenient to use. Furthermore, the program debugging method of the embodiment of the present application can also automatically calculate poor accuracy. For the specific implementation of the program debugging method, debugging tool, computer equipment, etc. of the embodiments of the present application, please refer to the following description.
  • Fig. 1 is a schematic structural diagram of a computer device provided by an embodiment of the present application.
  • the computer device 10 may include a general-purpose processor 101, a memory 102, a communication bus 103, a communication interface 104, and an artificial intelligence processor 105.
  • the general-purpose processor 101 and the artificial intelligence processor 105 pass through the communication bus.
  • 103 is connected to the memory 102 and the communication interface 103.
  • the general-purpose processor 101 may be a central processing unit (CPU), and the general-purpose processor 101 may also be other general-purpose processors, digital signal processors (Digital Signal Processor, DSP), and application specific integrated circuits (Application Specific Integrated Circuits). , ASIC), ready-made programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc.
  • the general-purpose processor may be a microprocessor or the general-purpose processor 101 may also be any conventional processor or the like.
  • the general-purpose processor 101 may also be an integrated circuit chip with signal processing capability.
  • each step of the program debugging method of the present application can be completed by an integrated logic circuit of hardware in the general-purpose processor 101 or instructions in the form of software.
  • the memory 102 may be a read-only memory (Read-Only Memory, ROM), a random access memory (Random Access Memory, RAM), or other memories.
  • the memory 102 is used to store data and various software programs.
  • the memory may be used to store a target program that runs during performance analysis.
  • the memory may include a physical device for storing information, and the information is usually digitized and then stored in a medium using electrical, magnetic, or optical methods.
  • the memory described in this embodiment may also include: devices that use electrical energy to store information, such as RAM, ROM, etc.; devices that use magnetic energy to store information, such as hard disks, floppy disks, magnetic tapes, magnetic core memories, bubble memory, U disks ; Devices that use optical methods to store information, such as compact discs (CDs) or digital video discs (Digital Video Discs, DVDs.)
  • CDs compact discs
  • DVDs Digital Video Discs
  • quantum memory graphene memory
  • the communication interface 104 uses a transceiving device such as but not limited to a transceiver to implement communication between the computer device 10 and other devices or a communication network.
  • a transceiving device such as but not limited to a transceiver to implement communication between the computer device 10 and other devices or a communication network.
  • the artificial intelligence processor 105 can be mounted on a general-purpose processor (such as a Host CPU) as a coprocessor, and the general-purpose processor assigns tasks to it.
  • the artificial intelligence processor 105 may be an application specific integrated circuit (ASIC), which can implement one or more operations, such as operations related to artificial neural networks.
  • the artificial intelligence processor 105 may be replaced with other processors such as a graphics processing unit (GPU) or DSP.
  • GPU graphics processing unit
  • DSP digital signal processor
  • the computer device 10 is only an example provided by the embodiment of the present application, and the computer device 10 may have more or less components than the components shown, may combine two or more components, or may have Different configurations of components are realized.
  • FIG. 2A is a schematic flowchart of a program debugging method provided by an embodiment of the application.
  • the method can be applied to a debugging tool that can run on a general-purpose processor such as a CPU to implement corresponding debugging.
  • the debugging tool may be a debugging tool such as GDB debugger (GNU Debugger, GDB), which is not specifically limited here.
  • the method includes:
  • the debugging tool obtains a first executable program and a second executable program.
  • the first executable program and the second executable program may be program codes obtained after the code to be debugged is compiled by a compiler.
  • the computer device may first obtain the code to be debugged, and then compile the code to be debugged by a compiler to obtain the first executable program and the second executable program.
  • the above-mentioned code to be debugged may be a code written for a dedicated processor in a high-level programming language (for example, C language or extended C language (such as CudaC, etc.)).
  • the dedicated processor may be an artificial intelligence processor, a GPU, or a tensor processor (Tensor Processing Unit, TPU), etc., which is not specifically limited here.
  • the code to be debugged may also be a code written for a general-purpose processor in a high-level programming language.
  • the first executable program is an executable program corresponding to the general-purpose processor, which is obtained after compiling the code to be debugged.
  • the second executable program is obtained after compiling the code to be debugged, and is an executable program corresponding to a processor such as an artificial intelligence processor, GPU, or TPU.
  • the compiler can compile the code to be debugged through different compile link options to obtain the first executable program corresponding to the general-purpose processor, and the second executable program corresponding to the artificial intelligence processor, GPU or TPU, etc. execute program.
  • the first executable program and the second executable program may be executable programs corresponding to the same processor, which are obtained by a compiler after compiling the code to be debugged.
  • both the first executable program and the second executable program are executable programs corresponding to the artificial intelligence processor.
  • both the first executable program and the second executable program are executable programs corresponding to the GPU or the TPU.
  • an emulator or compiler running in the computer device can obtain the aforementioned code to be debugged, and compile the aforementioned code to be debugged into the first executable program according to a compilation link option preset in the simulator or compiler. And the second executable program.
  • the aforementioned simulator can compile the code to be debugged into different versions by means of macro definition based on the code to be debugged, so that the aforementioned first executable program and the second executable program can be obtained.
  • the compilation process of the first executable program and the second executable program may also be obtained in other ways, which is not specifically limited here.
  • the debugging tool debugs the first executable program and the second executable program based on a first debugging operation for the first executable program or the second executable program.
  • the aforementioned debugging tool may be a preset debugging tool, for example, the debugging tool may be a GDB debugger.
  • the aforementioned debugging operations may refer to operations such as inserted checkpoints.
  • the GDB debugger can perform the same first debugging operation to debug the first executable program and the second executable program, so that the operation of one program can be applied to two programs at the same time, for example, Insert a breakpoint in one of the programs, and the GDB debugger can automatically insert a breakpoint in the corresponding position of the other program.
  • the debugging tool may simultaneously debug the first executable program and the second executable program according to the first debugging operation after receiving the first debugging operation for the first executable program or the second executable program.
  • the program that is, the first debugging operation can take effect on the first executable program and the second executable program at the same time, so that the synchronous debugging of the first executable program and the second executable program can be controlled more conveniently and intelligently.
  • the first debugging operation for the first executable program or the second executable program can be simultaneously performed on the first executable program and the second executable program through the debugging tool in the embodiment of the present application, so that the debugging tool can be used for debugging at the same time.
  • Two executable programs so as to realize the debugging of the two programs with faster operation, without printing, manual viewing or script comparison, and improving the debugging efficiency.
  • the data executed by the above-mentioned first executable program and the second executable program may have different precisions, so that debugging of the execution precision of the program can be realized by the debugging tool.
  • the accuracy of the first data corresponding to the first executable program may be greater than the accuracy of the second data corresponding to the second executable program.
  • the first executable program can implement operations on 32-bit floating point data
  • the second executable program can implement operations on 8-bit fixed point data.
  • the above-mentioned first executable program may be a program that meets accuracy requirements, and the accuracy debugging of the first executable program may be debugged through the simulator below, or through the debugging tool GDB (GNU Debugger) debugger Get it after debugging. Therefore, the debugging tool can debug the second executable program according to the acquired first executable program, so that the running result of the second executable program meets the preset requirement.
  • GDB GPU Debugger
  • the first debugging operation includes an inserted checkpoint; the debugging tool is based on the first debugging operation for the first executable program or the second executable program, and the debugging
  • the first executable program and the second executable program may include the following steps:
  • the debugging tool obtains the value of at least one first variable in the first executable program according to the corresponding first checkpoint in the first executable program or the second executable program, and the At least one second variable value in the second executable program, the at least one first variable value corresponds to the at least one second variable value one-to-one, and the first checkpoint is for the first executable program or The checkpoint inserted in the second executable program;
  • the debugging tool determines the running result of the second executable program according to the at least one first variable value and the at least one second variable value;
  • FIG. 2B is a schematic flowchart of steps for debugging the first executable program and the second executable program based on a first debugging operation according to an embodiment of the application, where the first debugging operation may be The operation input by the debugger, specifically, during the debugging process, the debugging tool runs the first executable program and the second executable program at the same time. During the process of running the first executable program and the second executable program, the debugging tool Can receive check points inserted by debuggers.
  • the first debugging operation may also be an operation preset in the debugging process.
  • the computer device may set checkpoints in advance for the program nodes that need to be checked in the program to be debugged, and the first debugging operation of inserting checkpoints Therefore, during the debugging process, when running to the program node where the first checkpoint is set, the first debugging operation can be executed, and the checkpoint can be inserted through the first debugging operation.
  • the value of at least one first variable in the first executable program and the value of the second executable program can be obtained.
  • At least one second variable value in this way, at least one first variable value and at least one second variable value corresponding to the first executable program or the second executable program can be obtained through a first debugging operation.
  • variable values may include data that needs to be calculated in the deep learning neural network, specifically the weight, the output data of each layer of the neural network, and the gradient value of each layer of the neural network (the gradient value may include the weight gradient and Input data gradient) and so on.
  • the above variable value can be a weight value.
  • the weight value in the neural network can be updated to obtain the updated weight value. New calculations are performed based on the updated weight value. Therefore, through continuous updating The weight value can train the neural network to make the calculation result of the neural network more accurate.
  • the same weight in the first executable program and the second executable program generated by the code to be debugged, the same weight may have different data types in the first executable program and the second executable program, for example, the same right
  • the value is represented as 16-bit floating point data in the first executable program, and as 8-bit fixed-point data in the second executable program.
  • the debugging tool may return to execute the debugging of the first executable program and the second executable program based on the first debugging operation for the first executable program or the second executable program, Until the running result of the second executable program meets the preset condition.
  • the debugging process of the gradient value and the output data is similar to the above-mentioned weight debugging process. For details, please refer to the above description, which will not be repeated here.
  • the operation result includes a loss of accuracy.
  • the following steps may also be included:
  • the first debugging operation of the program or the second executable program is to debug the first executable program and the second executable program.
  • the debugging tool can determine whether the accuracy loss of the second executable program meets a preset condition according to the value of at least one first variable and the value of at least one second variable, wherein the accuracy of the second data of the second executable program is lower than that of the first The first data accuracy of the executable program. If the accuracy loss of the second executable program does not meet the preset condition, it indicates that the accuracy error of the second executable program is relatively large. Therefore, the debugging tool can debug the second executable program when the accuracy loss of the second executable program does not meet the preset condition.
  • the debugging tool may suspend the execution of the first executable program and the second executable program, receive a second debugging operation for the second executable program, and perform an operation on the second executable program according to the second debugging operation.
  • Debug after debugging, return to execute the first debugging operation based on the first executable program or the second executable program through the debugging tool, and debug the first executable program and the second executable program. execute program.
  • the second debugging operation may be an operation input by the debugging personnel, and the computer device may receive the second debugging operation input by the debugging personnel to debug the second executable program whose accuracy loss does not meet the preset condition.
  • the second debugging operation may also be an operation preset in the debugging process.
  • the computer device may preset a second debugging operation for the accuracy loss of the second executable program that does not meet the preset condition, so that when determining After the accuracy loss of the second executable program does not meet the preset condition, a second debugging operation may be triggered, and the second executable program may be debugged according to the second debugging operation.
  • the value of at least one first variable in the first executable program is acquired according to the corresponding first checkpoint in the first executable program or the second executable program
  • at least one second variable value in the second executable program may include the following steps A1-step A3:
  • the debugging tool obtains the value of at least one first variable in the first executable program according to the first checkpoint inserted in the first executable program;
  • the debugging tool obtains the second executable program according to the first checkpoint inserted in the first executable program and the preset association relationship between the first executable program and the second executable program At least one second variable value in; or,
  • the debugging tool determines a second checkpoint for the second executable program according to the first checkpoint; acquires at least one second variable value in the second executable program according to the second checkpoint.
  • FIG. 2C is a schematic flowchart of steps for obtaining at least one first variable value in a first executable program and at least one second variable value in a second executable program according to an embodiment of the application.
  • the device may obtain the first operating data of the first executable program running to the first checkpoint according to the first checkpoint inserted into the first executable program, and obtain the first executable program from the first operating data The value of at least one first variable.
  • the debugging tool may preset a preset association relationship between the first executable program and the second executable program, and the preset association relationship is a semantic association relationship. Specifically, after obtaining the first checkpoint inserted in the first executable program, the debugging tool may determine the first code position in the first executable program where the first checkpoint is located, and then determine that it is in the second executable program The second code position with the same semantics as the first code position is obtained, and the second running data of the second executable program running to the second code position is obtained. Finally, at least the second executable program is obtained from the second running data. A second variable value.
  • the debugging tool may determine the second checkpoint for the second executable program according to the first checkpoint, and then obtain the second operating data of the second executable program running to the second checkpoint, from the second operating data Obtain at least one second variable value in the second executable program.
  • the debugging tool may determine the first code position of the first checkpoint in the first executable program, and then determine that the first checkpoint is located in the second executable program. A second code location with the same semantics as the first code location, and a second checkpoint is automatically inserted near the second code location accordingly. In this way, when the second executable program runs to the second checkpoint, the debugging tool can obtain the second operating data, and obtain at least one second variable value in the second executable program from the second operating data.
  • the value of at least one first variable in the first executable program is acquired according to the corresponding first checkpoint in the first executable program or the second executable program,
  • at least one second variable value in the second executable program may include the following steps A4-step A6:
  • the debugging tool obtains the value of at least one second variable in the second executable program according to the first checkpoint inserted in the second executable program;
  • the debugging tool obtains the first executable program according to the first checkpoint inserted in the second executable program and the preset association relationship between the first executable program and the second executable program At least one of the first variable values in; or,
  • the debugging tool determines a second checkpoint for the first executable program according to the first checkpoint; obtains at least one first variable value in the first executable program according to the second checkpoint.
  • FIG. 2D is a schematic flowchart of another step of obtaining at least one first variable value in a first executable program and at least one second variable value in a second executable program according to an embodiment of the application.
  • the debugging tool can obtain the second operating data of the second executable program running to the first checkpoint according to the first checkpoint inserted in the second executable program, and obtain the second executable data from the second operating data. At least one second variable value in the program is executed.
  • the debugging tool may preset a preset association relationship between the first executable program and the second executable program, and the preset association relationship is a semantic association relationship. Specifically, the debugging tool may determine the second code position corresponding to the first checkpoint in the second executable program after obtaining the first checkpoint inserted in the second executable program, and then the debugging tool may determine that the first checkpoint is in the first executable program. Execute the first code position in the program with the same semantics as the second code position, so as to obtain the first running data of the first executable program running to the first code position. Finally, the debugging tool obtains the first running data from the first running data. At least one first variable value in the executable program.
  • the debugging tool may determine the second checkpoint for the first executable program according to the first checkpoint, and then obtain the first operating data of the first executable program running to the second checkpoint, from the first operating data Obtain at least one first variable value in the first executable program.
  • the debugging tool can obtain at least one first variable value in the first executable program and at least one value in the second executable program according to the first checkpoint inserted into the first executable program or the second executable program.
  • a second variable value and further, it can be determined whether the accuracy loss of the second executable program meets the preset condition according to the at least one first variable value and the at least one second variable value. In this way, a relatively simple first debugging operation can be used Control the synchronization debugging of the first executable program and the second executable program more conveniently and intelligently.
  • determining the running result of the second executable program according to the at least one first variable value and the at least one second variable value may include the following steps:
  • the debugging tool determines the difference between each first variable value and the corresponding second variable value in the at least one first variable value, and obtains multiple differences;
  • FIG. 2E is a schematic diagram of a step flow diagram for determining the running result of a second executable program according to at least one first variable value and at least one second variable value according to an embodiment of the application, wherein the debugging tool may For each first variable value in at least one first variable value, the difference between the first variable value and the corresponding second variable value is determined, and if the difference is greater than a preset error threshold, the second variable value can be determined The accuracy loss of the executed program does not meet the preset condition.
  • step 22 after performing step 22, the following steps may be further included:
  • the accuracy loss of the second executable program satisfies the preset condition, it indicates that the first debugging operation is debugged, and the part between the first detection points in the second executable program runs correctly, and the first executable program can continue to be executed.
  • the execution program and the second executable program if the accuracy loss of the second executable program satisfies the preset condition, it indicates that the first debugging operation is debugged, and the part between the first detection points in the second executable program runs correctly, and the first executable program can continue to be executed.
  • the execution program and the second executable program if the accuracy loss of the second executable program satisfies the preset condition, it indicates that the first debugging operation is debugged, and the part between the first detection points in the second executable program runs correctly, and the first executable program can continue to be executed.
  • the execution program and the second executable program if the accuracy loss of the second executable program satisfies the preset condition, it indicates that the first debugging operation is
  • the computer device obtains the code to be debugged, generates the first executable program corresponding to the general-purpose processor according to the code to be debugged, and generates the second executable program corresponding to the artificial intelligence processor according to the code to be debugged.
  • Execute the program use the debugging tool to debug the first executable program and the second executable program based on the first debugging operation for the first executable program or the second executable program. In this way, both can be debugged at the same time by the debugging tool.
  • the executable program can be used to debug the two programs with a faster operation, without printing, manual viewing or script comparison, which improves the debugging efficiency.
  • FIG. 3 is a schematic flow diagram of another program debugging method provided by an embodiment of the application, which is used in a debugging tool, which can be run on a computer device to realize debugging of the code to be debugged, etc.
  • the debugging tool can be a debugging tool such as GDB.
  • the embodiment of the present application uses a heterogeneous system formed by an artificial intelligence processor and a general-purpose processor as an example to illustrate the working process of the GDB debugging tool. Specifically, the method includes:
  • a debugging tool acquires a first executable program and a second executable program.
  • the first executable program is an executable program corresponding to a general-purpose processor obtained by compiling the code to be debugged by a compiler or the like
  • the second executable program is an executable program obtained by compiling the code to be debugged by a compiler or the like, The executable program corresponding to the artificial intelligence processor.
  • step 301 For the specific implementation process of the foregoing step 301, reference may be made to the corresponding description in the method shown in FIG. 2A, which will not be repeated here.
  • the debugging tool obtains the value of at least one first variable in the first executable program according to the corresponding first checkpoint in the first executable program or the second executable program, and the At least one second variable value in the second executable program, the at least one first variable value corresponds to the at least one second variable value one-to-one, and the first checkpoint is for the first executable program or The checkpoint inserted in the second executable program.
  • the debugging tool in the debugging process, can run the first executable program and the second executable program at the same time.
  • the debugging tool can receive inspection inserted by the debugger. point.
  • the debugging tool can set checkpoints in advance for the program nodes that need to be checked in the program to be debugged, and insert the first debugging operation of the checkpoint, so that during the debugging process, the first executable program and the second executable program can be run at the same time.
  • the executable program when running to the program node where the first checkpoint is set, the first debugging operation can be executed, and the checkpoint is inserted through the first debugging operation.
  • the debugging tool can obtain the value of at least one first variable in the first executable program and the second executable program according to the first checkpoint inserted in the first executable program or the second executable program. At least one second variable value in the program. In this way, through a first debugging operation, at least one first variable value and at least one second variable value corresponding to the first executable program or the second executable program can be obtained one-to-one.
  • the debugging tool may determine whether the running result of the second executable program meets a preset condition according to the at least one first variable value and the at least one second variable value, and the running result may be the loss of accuracy of the second executable program, where, The second data accuracy of the second executable program is lower than the first data accuracy of the first executable program. If the accuracy loss of the second executable program does not meet the preset condition, it indicates that the accuracy error of the second executable program is relatively large. Therefore, when the accuracy loss of the second executable program does not meet the preset condition, the accuracy of the second executable program Second, the executable program is debugged.
  • the execution of the first executable program and the second executable program may be suspended, and the second executable program for the second executable program may be received.
  • the second debugging operation is to debug the second executable program according to the second debugging operation, and after debugging, return to execute the first debugging operation based on the first executable program or the second executable program through the debugging tool Debug the first executable program and the second executable program.
  • the second debugging operation may be an operation input by the debugging personnel, and the computer device may receive the second debugging operation input by the debugging personnel to debug the second executable program whose accuracy loss does not meet the preset condition.
  • the second debugging operation may also be an operation preset in the debugging process.
  • the computer device may preset a second debugging operation for the accuracy loss of the second executable program that does not meet the preset condition, so that when determining After the accuracy loss of the second executable program does not meet the preset condition, a second debugging operation may be triggered, and the second executable program may be debugged according to the second debugging operation.
  • the computer device obtains the code to be debugged, generates the first executable program corresponding to the general-purpose processor according to the code to be debugged, and generates the second executable program corresponding to the artificial intelligence processor according to the code to be debugged.
  • Execute the program and obtain at least one first variable value in the first executable program and at least one value in the second executable program according to the first checkpoint inserted in the first executable program or the second executable program through the debugging tool A second variable value, according to at least one first variable value and at least one second variable value to determine whether the running result of the second executable program meets the preset condition, and if the running result of the second executable program does not meet the preset condition, Return to the execution of the debugging tool based on the first debugging operation for the first executable program or the second executable program to debug the first executable program and the second executable program, so that the debugging tool is used to debug the two executable programs at the same time Programs, more convenient and intelligently control the synchronous debugging of the first executable program and the second executable program, so as to realize the debugging of the two programs with faster operation, without printing, manual viewing or script comparison, improving Debugging efficiency.
  • FIG. 4 is a schematic flowchart of another program debugging method provided by an embodiment of the application.
  • the embodiment of the application uses a heterogeneous system formed by an artificial intelligence processor and a general-purpose processor as an example to illustrate the GDB debugging tool Working process.
  • the method includes:
  • the debugging tool obtains the first executable program and the second executable program.
  • the first executable program is an executable program corresponding to a general-purpose processor obtained by compiling the code to be debugged
  • the second executable program is obtained by compiling the code to be debugged, corresponding to an artificial intelligence processor
  • the first data accuracy corresponding to the first executable program is greater than the second data accuracy corresponding to the second executable program.
  • the debugging tool acquires the value of at least one first variable in the first executable program according to the first checkpoint inserted in the first executable program.
  • the debugging tool obtains information in the second executable program according to the corresponding first checkpoint in the first executable program and the preset association relationship between the first executable program and the second executable program. At least one second variable value; or, determine the second checkpoint corresponding to the second executable program according to the first checkpoint; obtain at least one first checkpoint in the second executable program according to the second checkpoint Two variable values, the at least one first variable value corresponds to the at least one second variable value in a one-to-one correspondence.
  • the debugging tool determines whether the accuracy loss of the second executable program meets a preset condition according to the at least one first variable value and the at least one second variable value.
  • the debugging tool can obtain the first operating data of the first executable program running to the first checkpoint according to the first checkpoint inserted into the first executable program, and obtain the first executable data from the first operating data. At least one first variable value in the program is executed.
  • the debugging tool may preset a preset association relationship between the first executable program and the second executable program, and the preset association relationship is a semantic association relationship.
  • the debugging tool may be used in obtaining the first executable program. After inserting the first checkpoint, determine the first code location corresponding to the first checkpoint in the first executable program, and then the debugging tool can determine the second code in the second executable program that has the same semantics as the first code location Position, acquiring second operating data of the second executable program running to the second code location, and finally acquiring at least one second variable value in the second executable program from the second operating data.
  • the debugging tool may determine the second checkpoint for the second executable program according to the first checkpoint, and then obtain the second operating data of the second executable program running to the second checkpoint, from the second operating data Obtain at least one second variable value in the second executable program.
  • the computer device obtains the code to be debugged, generates the first executable program corresponding to the general-purpose processor according to the code to be debugged, and generates the second executable program corresponding to the artificial intelligence processor according to the code to be debugged.
  • Execute the program obtain the value of at least one first variable in the first executable program according to the first checkpoint inserted in the first executable program, and obtain the value of at least one first variable in the first executable program according to the first checkpoint inserted in the first executable program and the first checkpoint.
  • the executable program and the second executable program obtain the value of at least one second variable in the second executable program; or, determine the second checkpoint for the second executable program according to the first checkpoint;
  • the second checkpoint acquires at least one second variable value in the second executable program, and determines whether the accuracy loss of the second executable program meets the preset condition according to the at least one first variable value and the at least one second variable value.
  • the precision loss of the executable program does not meet the preset condition, the execution of the first executable program and the second executable program is suspended, the second debugging operation for the second executable program is received, and the second executable program is executed according to the second debugging operation.
  • first executable program and the second executable program are two executable programs corresponding to the same processor, and the first executable program and the second executable program have different execution precisions
  • the precision debugging process of the two pieces of executable program by the debugging tool is basically the same as the precision debugging process of the foregoing embodiment. For details, please refer to the above description, which will not be repeated here.
  • steps in the flowcharts of FIGS. 2A-4 are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear description in this article, there is no strict order for the execution of these steps, and these steps can be executed in other orders. Moreover, at least a part of the steps in FIGS. 2A-4 may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. These sub-steps or The execution order of the stages is not necessarily carried out sequentially, but may be executed alternately or alternately with at least a part of other steps or sub-steps or stages of other steps.
  • FIG. 5 is a schematic structural diagram of a program debugging device provided by an embodiment of the present application.
  • the debugging device may be a debugging tool such as GDB.
  • the apparatus 500 may at least include an obtaining unit 501 and a debugging unit 502, where:
  • the obtaining unit 501 is configured to obtain a first executable program and a second executable program, where the first executable program and the second executable program are programs compiled by the code to be debugged.
  • the debugging unit 502 is configured to debug the first executable program and the second executable program based on a first debugging operation for the first executable program or the second executable program through a debugging tool .
  • the first debugging operation includes an inserted checkpoint; in the debugging tool based on the first debugging operation for the first executable program or the second executable program, debugging Regarding the first executable program and the second executable program, the debugging unit 502 is specifically configured to:
  • the value of at least one first variable in the first executable program and the value in the second executable program are acquired At least one second variable value, the at least one first variable value corresponds to the at least one second variable value one-to-one, and the first checkpoint is for the first executable program or the second executable Checkpoints inserted in the program;
  • the running result includes a loss of accuracy; the debugging unit 502 is further configured to:
  • the execution of the first executable program and the second executable program is suspended, and then the execution of the debugging tool is based on the first executable program.
  • the first debugging operation of the program or the second executable program is executed, and the first executable program and the second executable program are debugged.
  • the debugging unit 502 is specifically configured to:
  • At least one first executable program in the second executable program is acquired Two-variable value;
  • the debugging unit 502 is specifically configured to:
  • At least one first executable program in the first executable program is acquired A variable value;
  • the debugging unit 502 specifically uses in:
  • the debugging unit 502 is further configured to:
  • the computer device obtains the code to be debugged, generates the first executable program corresponding to the general-purpose processor according to the code to be debugged, and generates the second executable program corresponding to the artificial intelligence processor according to the code to be debugged.
  • Execute the program use the debugging tool to debug the first executable program and the second executable program based on the first debugging operation for the first executable program or the second executable program. In this way, both can be debugged at the same time by the debugging tool.
  • the executable program can be used to debug the two programs with a faster operation, without printing, manual viewing or script comparison, which improves the debugging efficiency.
  • the above device embodiments are only illustrative, and the device of the present disclosure may also be implemented in other ways.
  • the division of units/modules in the above-mentioned embodiments is only a logical function division, and there may be other division methods in actual implementation.
  • multiple units, modules or components may be combined or integrated into another system, or some features may be omitted or not implemented.
  • the units or modules described as separate components may or may not be physically separate.
  • a component described as a unit or a module may be a physical unit or not a physical unit, that is, it may be located in one device, or may also be distributed on multiple devices.
  • the solutions of the embodiments of the present disclosure can be implemented by selecting some or all of the units according to actual needs.
  • the embodiment of the present application also provides a debugging tool that can run on a general-purpose processor such as a CPU to implement corresponding debugging functions.
  • the debugging tool may be a debugging tool such as GDB, which is not specifically limited here.
  • the debugging tool is used to perform the following steps:
  • the first executable program and the second executable program are debugged.
  • the first debugging operation includes an inserted checkpoint; the debugging tool debugs the first executable program based on the first debugging operation for the first executable program or the second executable program
  • the program and the second executable program include:
  • the value of at least one first variable in the first executable program and the value in the second executable program are acquired At least one second variable value, the at least one first variable value corresponds to the at least one second variable value one-to-one, and the first checkpoint is for the first executable program or the second executable Checkpoints inserted in the program;
  • the debugging tool obtains the value of at least one first variable in the first executable program according to the corresponding first checkpoint in the first executable program or the second executable program, and
  • the at least one second variable value in the second executable program includes:
  • At least one first executable program in the second executable program is acquired Two-variable value;
  • a second checkpoint for the second executable program is determined according to the first checkpoint; at least one second variable value in the second executable program is acquired according to the second checkpoint.
  • the debugging tool obtains the value of at least one first variable in the first executable program according to the corresponding first checkpoint in the first executable program or the second executable program, and
  • the at least one second variable value in the second executable program includes:
  • At least one first executable program in the first executable program is acquired A variable value;
  • the running result includes a loss of accuracy
  • the debugging tool is also used to:
  • the debugging tool determines that the accuracy loss of the second executable program does not meet the preset condition, suspend the execution of the first executable program and the second executable program, and then return to the execution of the first executable program based on the second executable program.
  • the first debugging operation of an executable program or the second executable program is to debug the first executable program and the second executable program.
  • the debugging tool to determine the running result of the second executable program according to the at least one first variable value and the at least one second variable value includes:
  • the debugging tool is also used to:
  • the embodiment of the present application also provides a computer storage medium for storing computer software instructions used by the computer equipment shown in FIGS. 2A to 4 above, which contains programs for executing the above method embodiments. By executing the stored program, the steps of the program debugging method of any of the above embodiments can be realized.
  • the embodiment of the present application also provides a computer program, the computer program includes program instructions, when the program instructions are executed by a processor, the processor executes the computer used by the computer device shown in FIGS. 2A-4 Software instructions, which include programs used to execute the foregoing method embodiments. By executing the stored program, the steps of the program debugging method of any of the above embodiments can be realized.
  • this application can be provided as methods, systems, or computer program products. Therefore, this application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, this application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, optical storage, etc.) containing computer-usable program codes.
  • a computer-usable storage media including but not limited to disk storage, optical storage, etc.
  • These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device.
  • the device implements the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
  • These computer program instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operation steps are executed on the computer or other programmable equipment to produce computer-implemented processing, so as to execute on the computer or other programmable equipment.
  • the instructions provide steps for implementing the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
  • the hardware may be digital circuits, analog circuits, and so on.
  • the physical realization of the hardware structure includes but is not limited to transistors, memristors and so on.
  • the artificial intelligence processor may be any appropriate hardware processor, such as CPU, GPU, FPGA, DSP, ASIC, and so on.
  • the memory can be any suitable magnetic storage medium or magneto-optical storage medium, such as resistive random access memory (RRAM), dynamic random access memory (DRAM), static Random access memory SRAM (Static Random-Access Memory), enhanced dynamic random access memory EDRAM (Enhanced Dynamic Random Access Memory), high-bandwidth memory HBM (High-Bandwidth Memory), hybrid storage cube HMC (Hybrid Memory Cube), etc. .
  • RRAM resistive random access memory
  • DRAM dynamic random access memory
  • SRAM Static Random-Access Memory
  • enhanced dynamic random access memory EDRAM Enhanced Dynamic Random Access Memory
  • high-bandwidth memory HBM High-Bandwidth Memory
  • hybrid storage cube HMC Hybrid Memory Cube
  • the integrated unit/module is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer readable memory.
  • the technical solution of the present disclosure essentially or the part that contributes to the existing technology or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a memory. It includes several instructions to make a computer device (which may be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods described in the various embodiments of the present disclosure.
  • the aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.
  • the integrated unit/module is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer readable memory.
  • the technical solution of the present disclosure essentially or the part that contributes to the existing technology or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a memory. It includes several instructions to make a computer device (which may be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods described in the various embodiments of the present disclosure.
  • the aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.
  • a program debugging method includes:
  • the first executable program and the second executable program are debugged.
  • the method according to A1 includes an inserted checkpoint; based on the first debugging operation for the first executable program or the second executable program, debugging the first
  • the executable program and the second executable program include:
  • the value of at least one first variable in the first executable program and the value in the second executable program are acquired At least one second variable value, the at least one first variable value corresponds to the at least one second variable value one-to-one, and the first checkpoint is for the first executable program or the second executable Checkpoints inserted in the program;
  • the operation result includes a loss of accuracy; the method further includes:
  • the execution of the first executable program and the second executable program is suspended, and then the execution of the debugging tool is based on the first executable program.
  • the first debugging operation of the program or the second executable program is executed, and the first executable program and the second executable program are debugged.
  • At least one first executable program in the second executable program is acquired Two-variable value;
  • Clause A5. The method according to A3, wherein according to the first checkpoint in the first executable program or the second executable program, at least one of the first executable programs is acquired.
  • the variable value and at least one second variable value in the second executable program include:
  • At least one first executable program in the first executable program is acquired A variable value;
  • a program debugging device comprising:
  • An obtaining unit configured to obtain a first executable program and a second executable program, where the first executable program and the second executable program are programs compiled by the code to be debugged;
  • the debugging unit is configured to use a debugging tool to debug the first executable program and the second executable program based on a first debugging operation for the first executable program or the second executable program.
  • the debugging unit is specifically configured to:
  • the value of at least one first variable in the first executable program and the value in the second executable program are acquired At least one second variable value, the at least one first variable value corresponds to the at least one second variable value one-to-one, and the first checkpoint is for the first executable program or the second executable Checkpoints inserted in the program;
  • the execution of the first executable program and the second executable program is suspended, and then the execution of the debugging tool is based on the first executable program.
  • the first debugging operation of the program or the second executable program is executed, and the first executable program and the second executable program are debugged.
  • the device characterized in that, in the first checkpoint corresponding to the first executable program or the second executable program, the information in the first executable program is acquired Regarding at least one first variable value and at least one second variable value in the second executable program, the debugging unit is specifically configured to:
  • At least one first executable program in the second executable program is acquired Two-variable value;
  • a second checkpoint for the second executable program is determined according to the first checkpoint; at least one second variable value in the second executable program is acquired according to the second checkpoint.
  • the debugging unit in the first checkpoint corresponding to the first executable program or the second executable program, acquiring at least one first checkpoint in the first executable program Regarding variable values and at least one second variable value in the second executable program, the debugging unit is specifically configured to:
  • At least one first executable program in the first executable program is acquired A variable value;
  • the debugging unit is specifically used for:
  • a computer device characterized by comprising a processor and a memory, the processor and the memory are connected to each other, wherein the processor includes a general-purpose processor and an artificial intelligence processor, and the memory is used to store a computer program
  • the computer program includes program instructions, and the processor is configured to invoke the program instructions to execute the method according to any one of claims A1-A7.
  • a computer-readable storage medium wherein the computer storage medium stores a computer program, and the computer program includes program instructions that, when executed by a processor, cause the processor to execute The method described in any one of A1-A7 is required.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

本申请实施例公开了一种程序调试方法、装置、计算机设备和存储介质,通过预设的调试工具同时执行不同的两个可执行程序,进而对两个可执行程序进行调试。

Description

程序调试方法、装置、调试工具和计算机设备 技术领域
本申请涉及计算机技术领域,尤其涉及一种程序调试方法、装置、调试工具和计算机设备。
背景技术
传统技术中,调试工具针对异构***的代码进行调试时,往往需要增加打印和代码的重复编译,这样使得调试工具工作量很大,调试过程比较复杂。在异构***中的不同处理器处理的数据类型及精度不同时,更加增加了代码调试的难度。例如,在不同处理器处理的数据类型及精度不同时,往往需要运行两个调试工具,并且需要人工查看或者手动写脚本计算精度,传统技术中的代码调试效率低且容易出错。
发明内容
本申请实施例提供一种程序调试方法、装置、调试工具、计算机设备和存储介质,可通过预设的调试工具同时执行不同处理器生成的两个可执行程序,进而对人工智能处理器对应的可执行程序进行调试。
第一方面,本申请实施例提供了一种程序调试方法,该方法包括:
获取第一可执行程序和第二可执行程序,其中,所述第一可执行程序与所述第二可执行程序为待调试代码编译后的程序。
第二方面,本申请实施例提供了一种程序调试装置,该装置可以包括:
获取单元,用于获取第一可执行程序和第二可执行程序,其中,所述第一可执行程序与所述第二可执行程序为待调试代码编译后的程序;
调试单元,用于基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序。
第三方面,本申请实施例提供了一种计算机设备,包括处理器和存储器,所述处理器和存储器相互连接,其中,所述处理器包括通用处理器和人工智能处理器,所述存储器用于存储支持计算机设备执行上述方法的计算机程序,所述计算机程序包括程序指令,所述处理器被配置用于调用所述程序指令,执行上述第一方面的方法。
第四方面,本申请实施例提供了一种计算机可读存储介质,所述计算机存储介质存储有计算机程序,所述计算机程序包括程序指令,所述程序指令当被处理器执行时使所述处理器执行上述第一方面的方法。
第五方面,本申请实施例提供了一种计算机程序,所述计算机程序包括程序指令,所述程序指令当被处理器执行时使所述处理器执行上述第一方面的方法。
第六方面,本申请实施例还提供了一种调试工具,所述调试工具用于执行如下步骤:
获取第一可执行程序和第二可执行程序,其中,所述第一可执行程序与所述第二可执行程序为待调试代码编译后的程序;
基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序。
附图说明
为了更清楚地说明本申请实施例技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍。
图1是本申请实施例提供的一种计算机设备的结构示意图;
图2A是本申请实施例提供的一种程序调试方法的流程示意图;
图2B是本申请实施例提供的一种基于第一调试操作调试所述第一可执行程序和所述第二可执行程序的步骤流程示意图;
图2C是本申请实施例提供的一种获取第一可执行程序中的至少一个第一变量值,以及第二可执行程序中至少一个第二变量值的步骤流程示意图;
图2D是本申请实施例提供的另一种获取第一可执行程序中的至少一个第一变量值,以及第二可执行程序中至少一个第二变量值的步骤流程示意图;
图2E是本申请实施例提供的一种根据至少一个第一变量值和至少一个第二变量值,确定第二可执行程序的运行结果的步骤流程示意图;
图3是本申请实施例公开的另一种程序调试方法的流程示意图;
图4是本申请实施例公开的另一种程序调试方法的流程示意图;
图5是本申请实施例提供的一种程序调试装置的结构示意图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行描述。
应当理解,应当理解,本披露的权利要求、说明书及附图中的术语“第一”、“第二”等是用于区别不同对象,而不是用于描述特定顺序。本披露的说明书和权利要求书中使用的术语“包括”和“包含”指示所描述特征、整体、步骤、操作、元素和/或组件的存在,但并不排除一个或多个其它特征、整体、步骤、操作、元素、组件和/或其集合的存在或添加。
还应当理解,在此本披露说明书中所使用的术语仅仅是出于描述特定实施例的目的,而并不意在限定本披露。如在本披露说明书和权利要求书中所使用的那样,除非上下文清楚地指明其它情况,否则单数形式的“一”、“一个”及“该”意在包括复数形式。还应当进一步理解,在本披露说明书和权利要求书中使用的术语“和/或”是指相关联列出的项中的一个或多个的任何组合以及所有可能组合,并且包括这些组合。
如在本说明书和权利要求书中所使用的那样,术语“如果”可以依据上下文被解释为“当...时”或“一旦”或“响应于确定”或“响应于检测到”。类似地,短语“如果确定”或“如果检测到[所描述条件或事件]”可以依据上下文被解释为意指“一旦确定”或“响应于确定”或“一旦检测到[所描述条件或事件]”或“响应于检测到[所描述条件或事件]”。
传统技术中,调试工具针对异构***的代码进行调试时,往往需要增加打印和代码的重复编译,这样使得调试工具工作量很大,调试过程比较复杂。在异构***中的不同处理器处理的数据类型及精度不同时,更加增加了代码调试的难度。例如,在不同处理器处理的数据类型及精度不同时,往往需要运行两个调试工具,并且需要人工查看或者手动写脚本计算精度,传统技术中的代码调试效率低且容易出错。应当清楚的是,不同数据类型的 数据精度不同。数据精度越大,计算产生的功耗和运行时间越大,数据精度越小,计算产生的功耗和运算时间越小。因而低精度数据的运算能给程序的运行性能和运算产生的功耗带来巨大的好处,在某些计算中,低精度计算能够在较小运行结果的前提下大大提高运行速率。
基于现有技术中存在的问题,本申请实施例提供了一种程序调试方法,该程序调试方式能够实现对异构***中具有不同精度的代码的调试。进一步地,本申请实施例的程序调试方法还可以采用同一调试工具实现不同精度的代码的同时调试,避免了调试工具之间的切换,方便使用。更进一步地,本申请实施例的程序调试方法还可以自动计算精度差。本申请实施例的程序调试方法及调试工具、计算机设备等的具体实现可参见下文的描述。
图1是本申请实施例提供的一种计算机设备的结构示意图。如图1所示,计算机设备10可以包括通用处理器101、存储器102、通信总线103、通信接口104和人工智能处理器105,其中,通用处理器101、人工智能处理器105通过所述通信总线103连接所述存储器102和所述通信接口103。
通用处理器101可以是中央处理单元(Central Processing Unit,CPU),该通用处理器101还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该通用处理器101也可以是任何常规的处理器等。在可选地实施例中,通用处理器101还可以是一种具有信号的处理能力的集成电路芯片。在实现过程中,本申请的程序调试方法的各个步骤可以通过通用处理器101中的硬件的集成逻辑电路或者软件形式的指令完成。
存储器102可以是只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)或其他存储器。本申请实施例中,存储器102用于存储数据以及各种软件程序,例如本申请实施例中,存储器可以用于存储进行性能分析过程中运行的目标程序。
可选的,在本申请实施例中,所述存储器可以包括用于存储信息的物理装置,通常是将信息数字化后再以利用电、磁或者光学等方法的媒体加以存储。本实施方式所述的存储器又可以包括:利用电能方式存储信息的装置,如RAM、ROM等;利用磁能方式存储信息的装置,如硬盘、软盘、磁带、磁芯存储器、磁泡存储器、U盘;利用光学方式存储信息的装置,如光盘(Compact Disc,CD)或数字视频光盘(Digital Video Disc,DVD。)当然,还有其他方式的存储器,例如量子存储器、石墨烯存储器等等。
通信接口104使用例如但不限于收发器一类的收发装置,来实现计算机设备10与其他设备或通信网络之间的通信。
人工智能处理器105可以作为协处理器挂载到通用处理器(如Host CPU)上,由通用处理器为其分配任务。在实际应用中,人工智能处理器105可以是专用集成电路(Application Specific Integrated Circuit,ASIC),其能够实现一种或多种运算,如人工神经网络相关的运算。在其他实施例中,该人工智能处理器105可以替换为图形处理器(Graphics Processing Unit,GPU)或DSP等其他处理器,此处仅以举例说明,并不用于限定本申请。
应当理解,计算机设备10仅为本申请实施例提供的一个例子,并且,计算机设备10可具有比示出的部件更多或更少的部件,可以组合两个或更多个部件,或者可具有部件的不同配置实现。
如图2A所示,图2A为本申请实施例提供的一种程序调试方法的流程示意图,该方法 可以应用于调试工具中,该调试工具能够在CPU等通用处理器上运行以实现相应的调试功能。可选地,该调试工具可以是GDB调试器(GNU Debugger,GDB)等调试工具,此处不做具体限定。所述方法包括:
201、调试工具获取第一可执行程序和第二可执行程序。
其中,所述第一可执行程序与所述第二可执行程序可以为待调试代码经编译器编译后获得的程序代码。本申请实施例中,计算机设备可先获取待调试代码,然后通过编译器对待调试代码进行编译,得到第一可执行程序和第二可执行程序。
上述待调试代码可以是采用高级编程语言(例如,C语言或扩展的C语言(如CudaC等))针对专用处理器编写的代码。可选地,该专用处理器可以是人工智能处理器、GPU或张量处理器(Tensor Processing Unit,TPU)等等,此处不做具体限定。可选地,该待调试代码也可以是采用高级编程语言针对通用处理器编写的代码。
可选地,第一可执行程序是对待调试代码进行编译后获得的,与所述通用处理器对应的可执行程序。第二可执行程序是对所述待调试代码进行编译后获得的,与人工智能处理器、GPU或TPU等处理器对应的可执行程序。本申请实施例中,编译器可通过不同的编译链接选项对待调试代码进行编译,得到通用处理器对应的第一可执行程序,以及人工智能处理器、GPU或TPU等处理器对应的第二可执行程序。
可选地,该第一可执行程序和第二可执行程序可以是编译器对待调试代码进行编译后获得的,与同一处理器对应的可执行程序。例如,该第一可执行程序和第二可执行程序均是与人工智能处理器对应的可执行程序。或者,该第一可执行程序和第二可执行均是与GPU或TPU对应的可执行程序。
可选地,计算机设备中运行的模拟器或编译器等可以获取上述的待调试代码,并根据模拟器或编译器中预设的编译链接选项将上述的待调试代码编译为第一可执行程序和第二可执行程序。具体地,上述模拟器可以基于该待调试代码,通过宏定义的方式将该待调试代码编译为不同的版本,从而可以获得上述的第一可执行程序和第二可执行程序。在其他实施例中,第一可执行程序和第二可执行程序的编译过程还可以通过其他方式获得,此处不做具体限定。
202、所述调试工具基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序。
其中,上述调试工具可以为预先设定的调试工具,例如,调试工具可以是GDB调试器。上述的调试操作可以是指***的检查点等操作。本申请实施例中,GDB调试器可以同一第一调试操作,实现对于第一可执行程序和第二可执行程序的调试,从而实现对于一个程序的操作同时作用于两份程序上,例如,在其中一个程序中***断点,GDB调试器可自动在另一程序的相应位置***断点。
本申请实施例中,调试工具可以在接收到针对第一可执行程序或第二可执行程序的第一调试操作后,根据该第一调试操作,同时调试第一可执行程序和第二可执行程序,即第一调试操作同时可对第一可执行程序和第二可执行程序生效,从而,可更加便捷、智能地对第一可执行程序和第二可执行程序的同步调试进行控制。
可见,本申请实施例通过调试工具可实现针对第一可执行程序或第二可执行程序的第一调试操作同时作用于第一可执行程序和第二可执行程序,从而可通过调试工具同时调试两个可执行程序,从而实现以更快速的操作对两个程序进行调试,无需通过打印、人工查看或者脚本对比,提高调试效率。
可选地,上述的第一可执行程序和第二可执行程序执行的数据可以具有不同的精度,从而可以通过该调试工具实现程序的执行精度调试。可选地,第一可执行程序对应的第一 数据精度可以大于第二可执行程序对应的第二数据精度。例如,第一可执行程序可以实现32位浮点数据的运算,第二可执行程序可以实现8位定点数据的运算。
可选地,上述第一可执行程序可以是满足精度要求的程序,该第一可执行程序的精度调试可以是通过下文中的模拟器进行调试,也可以通过调试工具GDB(GNU Debugger)调试器进行调试得到。因而,调试工具可以根据获取的第一可执行程序对第二可执行程序进行调试,以使得第二可执行程序的运行结果满足预设要求。
可选地,上述步骤202中,所述第一调试操作包括***的检查点;所述调试工具基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序,可包括以下步骤:
21、所述调试工具根据所述第一可执行程序或所述第二可执行程序中对应的第一检查点,获取所述第一可执行程序中的至少一个第一变量值,以及所述第二可执行程序中至少一个第二变量值,所述至少一个第一变量值与所述至少一个第二变量值一一对应,所述第一检查点为针对所述第一可执行程序或所述第二可执行程序中***的检查点;
22、调试工具根据所述至少一个第一变量值和所述至少一个第二变量值,确定所述第二可执行程序的运行结果;
23、当所述第二可执行程序的运行结果不满足预设条件时,则返回执行通过调试工具基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序,直至所述第二可执行程序的运行结果满足所述预设条件。
请参阅图2B,图2B为本申请实施例提供的一种基于第一调试操作调试所述第一可执行程序和所述第二可执行程序的步骤流程示意图,其中,第一调试操作可以是由调试人员输入的操作,具体地,在调试过程中,调试工具同时运行第一可执行程序和第二可执行程序,在运行第一可执行程序和第二可执行程序的过程中,调试工具可接收调试人员***的检查点。可选地,第一调试操作也可以是预先设置于调试流程中的操作,具体地,计算机设备可预先针对待调试程序中需要检查的程序节点设置检查点,以及***检查点的第一调试操作,从而,在调试过程中,当运行至设置了第一检查点的程序节点时,可执行该第一调试操作,通过该第一调试操作***检查点。
本申请实施例中,可根据针对第一可执行程序或第二可执行程序中***的第一检查点,获取第一可执行程序中的至少一个第一变量值,以及第二可执行程序中至少一个第二变量值,如此,可通过一个第一调试操作,针对第一可执行程序或第二可执行程序获取一一对应的至少一个第一变量值和至少一个第二变量值。
其中,上述变量值可以包括深度学习神经网络中需要计算的数据,具体可包括权值、神经网络每一层的输出数据,神经网络每一层的梯度值(该梯度值可以包括权值梯度和输入数据梯度)等。
例如,上述变量值可以是权值,在神经网络运算中,可对神经网络中的权值进行更新,得到更新后的权值,根据更新后的权值进行新的运算,因此,通过不断更新权值,可对神经网络进行训练,以使神经网络的运算结果更加准确。本申请实施例中,待调试代码生成的第一可执行程序和第二可执行程序中,同一权值在第一可执行程序和第二可执行程序的数据类型可能不同,例如,同一个权值在第一可执行程序中表示为16bit的浮点数据,在第二可执行程序中表示为8bit的定点数据。因此,可通过一个第一调试操作,针对同一个变量的值,获取在第一可执行程序的值和在第二可执行程序的值,进而,通过至少一个第一变量值和至少一个第二变量值确定第一可执行程序的数据和第二可执行程序的数据之间的精度差。当第二可执行程序的运行结果不满足预设条件时,则暂停执行所述第一可执行程序和所述第二可执行程序。进一步地,可返回执行所述调试工具基于针对所述第一可执行 程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序,直至第二可执行程序的运行结果满足预设条件。可选地,梯度值和输出数据的调试过程与上述权值的调试过程类似,具体可参见上文的描述,此处不再赘述。
可选地,所述运行结果包括精度损失,上述步骤202中,还可包括以下步骤:
若所述第二可执行程序的精度损失不满足预设条件,暂停执行所述第一可执行程序和所述第二可执行程序,之后返回执行所述调试工具基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序。
其中,调试工具可根据至少一个第一变量值和至少一个第二变量值确定第二可执行程序的精度损失是否满足预设条件,其中,第二可执行程序的第二数据精度低于第一可执行程序的第一数据精度。若所述第二可执行程序的精度损失不满足预设条件,表明第二可执行程序的精度误差较大。因此,调试工具可在第二可执行程序的精度损失不满足预设条件时,对第二可执行程序进行调试。具体地,调试工具可暂停执行所述第一可执行程序和所述第二可执行程序,接收针对所述第二可执行程序的第二调试操作,根据第二调试操作对第二可执行程序进行调试,调试之后,返回执行所述通过调试工具基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序。
其中,第二调试操作可以是由调试人员输入的操作,计算机设备可接收调试人员输入的第二调试操作对精度损失不满足预设条件的第二可执行程序进行调试。或者,第二调试操作还可以是预先设置于调试流程中的操作,具体地,计算机设备可预先设置针对第二可执行程序的精度损失不满足预设条件的第二调试操作,从而,在确定第二可执行程序的精度损失不满足预设条件后,可触发第二调试操作,并根据第二调试操作对第二可执行程序进行调试。
可选地,上述步骤21中,根据所述第一可执行程序或所述第二可执行程序中对应的第一检查点,获取所述第一可执行程序中的至少一个第一变量值,以及所述第二可执行程序中至少一个第二变量值,可包括以下步骤A1-步骤A3:
A1、调试工具根据针对所述第一可执行程序中***的第一检查点,获取所述第一可执行程序中的至少一个第一变量值;
A2、调试工具根据针对所述第一可执行程序中***的第一检查点以及所述第一可执行程序与所述第二可执行程序的预设关联关系,获取所述第二可执行程序中至少一个第二变量值;或者,
A3、调试工具根据所述第一检查点确定针对所述第二可执行程序的第二检查点;根据所述第二检查点获取所述第二可执行程序中至少一个第二变量值。
请参阅图2C,图2C为本申请实施例提供的一种获取第一可执行程序中的至少一个第一变量值,以及第二可执行程序中至少一个第二变量值的步骤流程示意图,计算机设备可根据针对第一可执行程序中***的第一检查点,获取第一可执行程序运行至该第一检查点的第一运行数据,从该第一运行数据中获取第一可执行程序中的至少一个第一变量值。
其中,调试工具可预先设置第一可执行程序与所述第二可执行程序的预设关联关系,该预设关联关系为语义关联关系。具体地,调试工具可在获取第一可执行程序中***的第一检查点后,确定第一可执行程序中第一检查点所在的第一代码位置,然后,确定在第二可执行程序中与第一代码位置语义相同的第二代码位置,获取第二可执行程序运行至该第二代码位置的第二运行数据,最后,从该第二运行数据中获取第二可执行程序中的至少一个第二变量值。
或者,调试工具可根据第一检查点确定针对第二可执行程序的第二检查点,然后获取 第二可执行程序运行至该第二检查点的第二运行数据,从该第二运行数据中获取第二可执行程序中的至少一个第二变量值。具体地,调试工具可以在获取第一可执行程序中***的第一检查点后,确定第一可执行程序中第一检查点所在的第一代码位置,然后确定在第二可执行程序中与第一代码位置语义相同的第二代码位置,并相应在该第二代码位置附近自动***第二检查点。这样当第二可执行程序运行至该第二检查点时,调试工具可以获得第二运行数据,从该第二运行数据中获取第二可执行程序中的至少一个第二变量值。
可选地,上述步骤21中,根据所述第一可执行程序或所述第二可执行程序中对应的第一检查点,获取所述第一可执行程序中的至少一个第一变量值,以及所述第二可执行程序中至少一个第二变量值,可包括以下步骤A4-步骤A6:
A4、调试工具根据针对所述第二可执行程序中***的第一检查点,获取所述第二可执行程序中的至少一个第二变量值;
A5、调试工具根据针对所述第二可执行程序中***的第一检查点以及所述第一可执行程序与所述第二可执行程序的预设关联关系,获取所述第一可执行程序中至少一个第一变量值;或者,
A6、调试工具根据所述第一检查点确定针对所述第一可执行程序的第二检查点;根据所述第二检查点获取所述第一可执行程序中至少一个第一变量值。
请参阅图2D,图2D为本申请实施例提供的另一种获取第一可执行程序中的至少一个第一变量值,以及第二可执行程序中至少一个第二变量值的步骤流程示意图,其中,调试工具可根据针对第二可执行程序中***的第一检查点,获取第二可执行程序运行至该第一检查点的第二运行数据,从该第二运行数据中获取第二可执行程序中的至少一个第二变量值。
其中,调试工具可预先设置第一可执行程序与所述第二可执行程序的预设关联关系,该预设关联关系为语义关联关系。具体地,调试工具可在获取第二可执行程序中***的第一检查点后,确定第二可执行程序中第一检查点对应的第二代码位置,然后,调试工具可确定在第一可执行程序中与第二代码位置语义相同的第一代码位置,从而获取第一可执行程序运行至该第一代码位置的第一运行数据,最后,调试工具从该第一运行数据中获取第一可执行程序中的至少一个第一变量值。
或者,调试工具可根据第一检查点确定针对第一可执行程序的第二检查点,然后获取第一可执行程序运行至该第二检查点的第一运行数据,从该第一运行数据中获取第一可执行程序中的至少一个第一变量值。
可见,调试工具通过根据针对第一可执行程序或第二可执行程序中***的第一检查点,可获取第一可执行程序中的至少一个第一变量值,以及第二可执行程序中至少一个第二变量值,进而,可根据至少一个第一变量值和至少一个第二变量值确定第二可执行程序的精度损失是否满足预设条件,如此,可通过较为简单的第一调试操作,更加便捷、智能地对第一可执行程序和第二可执行程序的同步调试进行控制。
可选地,上述步骤22中,根据所述至少一个第一变量值和所述至少一个第二变量值,确定所述第二可执行程序的运行结果,可包括以下步骤:
B1、调试工具确定所述至少一个第一变量值中每一第一变量值与对应的第二变量值之间的差值,得到多个差值;
B2、若所述多个差值中存在大于所述预设的误差阈值的差值,确定所述第二可执行程序的精度损失不满足预设条件;
B3、若所述多个差值均小于或等于所述预设的误差阈值的差值,确定所述第二可执行程序的精度损失满足所述预设条件。
请参阅图2E,图2E为本申请实施例提供的一种根据至少一个第一变量值和至少一个第二变量值,确定第二可执行程序的运行结果的步骤流程示意图,其中,调试工具可针对至少一个第一变量值中每一第一变量值,确定该第一变量值与对应的第二变量值之间的差值,若该差值大于预设的误差阈值,可确定第二可执行程序的精度损失不满足预设条件,若确定至少一个第一变量值中每一第一变量值与对应的第二变量值之间的差值,得到多个差值后,多个差值小于或等于预设的误差阈值,则可确定第二可执行程序的精度损失满足预设条件。
可选地,本申请实施例中,在执行所述步骤22后,还可包括以下步骤:
若所述第二可执行程序的精度损失满足所述预设条件,继续执行所述第一可执行程序和所述第二可执行程序。
其中,若第二可执行程序的精度损失满足所述预设条件,表明针对第一调试操作进行调试,第二可执行程序中第一检测点之间的部分运行正确,可以继续执行第一可执行程序和第二可执行程序。
可以看出,本申请提供的技术方案,计算机设备通过获取待调试代码,根据待调试代码生成通用处理器对应的第一可执行程序,以及根据待调试代码生成人工智能处理器对应的第二可执行程序,通过调试工具基于针对第一可执行程序或第二可执行程序的第一调试操作,调试第一可执行程序和所述第二可执行程序,如此,可通过调试工具同时调试两个可执行程序,从而实现以更快速的操作对两个程序进行调试,无需通过打印、人工查看或者脚本对比,提高调试效率。
如图3所示,图3为本申请实施例提供的另一种程序调试方法的流程示意图,用于调试工具中,该调试工具可以在计算机设备上运行,以实现对待调试代码等进行调试的功能,该调试工具可以是GDB等调试工具。本申请实施例以人工智能处理器和通用处理器形成的异构***为例说明该GDB调试工具的工作过程。具体地,所述方法包括:
301、调试工具获取第一可执行程序和第二可执行程序。
其中,所述第一可执行程序是编译器等对待调试代码编译获得的,与通用处理器对应的可执行程序,所述第二可执行程序是编译器等对所述待调试代码编译获得,与人工智能处理器对应的可执行程序。
其中,上述步骤301的具体实现过程可参照图2A所示的方法中相应的描述,在此不再赘述。
302、所述调试工具根据所述第一可执行程序或所述第二可执行程序中对应的第一检查点,获取所述第一可执行程序中的至少一个第一变量值,以及所述第二可执行程序中至少一个第二变量值,所述至少一个第一变量值与所述至少一个第二变量值一一对应,所述第一检查点为针对所述第一可执行程序或所述第二可执行程序中***的检查点。
303、根据所述至少一个第一变量值和所述至少一个第二变量值,确定所述第二可执行程序的运行结果。
304、当所述第二可执行程序的运行结果不满足预设条件时,则返回执行通过调试工具基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序,直至所述第二可执行程序的运行结果满足所述预设条件。
其中,在调试过程中,调试工具可以同时运行第一可执行程序和第二可执行程序,在运行第一可执行程序和第二可执行程序的过程中,调试工具可接收调试人员***的检查点。可选地,调试工具可预先针对待调试程序中需要检查的程序节点设置检查点,以及***检查点的第一调试操作,从而,在调试过程中,可同时运行第一可执行程序和第二可执行程 序,当运行至设置了第一检查点的程序节点时,可执行该第一调试操作,通过该第一调试操作***检查点。
本申请实施例中,调试工具可根据针对第一可执行程序或第二可执行程序中***的第一检查点,获取第一可执行程序中的至少一个第一变量值,以及第二可执行程序中至少一个第二变量值,如此,可通过一个第一调试操作,针对第一可执行程序或第二可执行程序获取一一对应的至少一个第一变量值和至少一个第二变量值。
进一步地,调试工具可根据至少一个第一变量值和至少一个第二变量值确定第二可执行程序的运行结果是否满足预设条件,运行结果可以为第二可执行程序的精度损失,其中,第二可执行程序的第二数据精度低于第一可执行程序的第一数据精度。若所述第二可执行程序的精度损失不满足预设条件,表明第二可执行程序的精度误差较大,因此,可在第二可执行程序的精度损失不满足预设条件时,对第二可执行程序进行调试。具体地,若所述第二可执行程序的精度损失不满足预设条件,可暂停执行所述第一可执行程序和所述第二可执行程序,接收针对所述第二可执行程序的第二调试操作,根据第二调试操作对第二可执行程序进行调试,调试之后,返回执行所述通过调试工具基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序。
其中,第二调试操作可以是由调试人员输入的操作,计算机设备可接收调试人员输入的第二调试操作对精度损失不满足预设条件的第二可执行程序进行调试。或者,第二调试操作还可以是预先设置于调试流程中的操作,具体地,计算机设备可预先设置针对第二可执行程序的精度损失不满足预设条件的第二调试操作,从而,在确定第二可执行程序的精度损失不满足预设条件后,可触发第二调试操作,并根据第二调试操作对第二可执行程序进行调试。
可以看出,本申请提供的技术方案,计算机设备通过获取待调试代码,根据待调试代码生成通用处理器对应的第一可执行程序,以及根据待调试代码生成人工智能处理器对应的第二可执行程序,通过调试工具根据针对第一可执行程序或第二可执行程序中***的第一检查点,获取第一可执行程序中的至少一个第一变量值,以及第二可执行程序中至少一个第二变量值,根据至少一个第一变量值和至少一个第二变量值确定第二可执行程序的运行结果是否满足预设条件,若第二可执行程序的运行结果不满足预设条件,返回执行所述通过调试工具基于针对第一可执行程序或第二可执行程序的第一调试操作,调试第一可执行程序和第二可执行程序,如此,通过调试工具同时调试两个可执行程序,更加便捷、智能地对第一可执行程序和第二可执行程序的同步调试进行控制,从而实现以更快速的操作对两个程序进行调试,无需通过打印、人工查看或者脚本对比,提高调试效率。
如图4所示,图4为本申请实施例提供的另一种程序调试方法的流程示意图,本申请实施例以人工智能处理器和通用处理器形成的异构***为例说明该GDB调试工具的工作过程。所述方法包括:
401、调试工具获取第一可执行程序和第二可执行程序。
其中,所述第一可执行程序是对待调试代码编译获得的,与通用处理器对应的可执行程序,所述第二可执行程序是对所述待调试代码编译获得,与人工智能处理器对应的可执行程序,所述第一可执行程序对应的第一数据精度大于所述第二可执行程序对应的第二数据精度。
402、所述调试工具根据针对所述第一可执行程序中***的第一检查点,获取所述第一可执行程序中的至少一个第一变量值。
其中,上述步骤401-402的具体实现过程可参照图2A所示的方法中相应的描述,在此 不再赘述。
403、调试工具根据所述第一可执行程序中对应的第一检查点以及所述第一可执行程序与所述第二可执行程序的预设关联关系,获取所述第二可执行程序中至少一个第二变量值;或者,根据所述第一检查点确定所述第二可执行程序对应的第二检查点;根据所述第二检查点获取所述第二可执行程序中至少一个第二变量值,所述至少一个第一变量值与所述至少一个第二变量值一一对应。
404、调试工具根据所述至少一个第一变量值和所述至少一个第二变量值确定所述第二可执行程序的精度损失是否满足预设条件。
405、若所述第二可执行程序的精度损失不满足预设条件,暂停执行所述第一可执行程序和所述第二可执行程序,接收针对所述第二可执行程序的第二调试操作,根据所述第二调试操作对所述第二可执行程序进行调试,之后返回执行所述通过调试工具基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序。
其中,调试工具可根据针对第一可执行程序中***的第一检查点,获取第一可执行程序运行至该第一检查点的第一运行数据,从该第一运行数据中获取第一可执行程序中的至少一个第一变量值。
其中,调试工具可预先设置第一可执行程序与所述第二可执行程序的预设关联关系,该预设关联关系为语义关联关系,具体地,调试工具可在获取第一可执行程序中***的第一检查点后,确定第一可执行程序中第一检查点对应的第一代码位置,然后,调试工具可确定在第二可执行程序中与第一代码位置语义相同的第二代码位置,获取第二可执行程序运行至该第二代码位置的第二运行数据,最后,从该第二运行数据中获取第二可执行程序中的至少一个第二变量值。
或者,调试工具可根据第一检查点确定针对第二可执行程序的第二检查点,然后获取第二可执行程序运行至该第二检查点的第二运行数据,从该第二运行数据中获取第二可执行程序中的至少一个第二变量值。
可以看出,本申请提供的技术方案,计算机设备通过获取待调试代码,根据待调试代码生成通用处理器对应的第一可执行程序,以及根据待调试代码生成人工智能处理器对应的第二可执行程序,根据针对第一可执行程序中***的第一检查点,获取第一可执行程序中的至少一个第一变量值,根据针对第一可执行程序中***的第一检查点以及第一可执行程序与第二可执行程序的预设关联关系,获取第二可执行程序中至少一个第二变量值;或者,根据第一检查点确定针对第二可执行程序的第二检查点;根据第二检查点获取第二可执行程序中至少一个第二变量值,根据至少一个第一变量值和至少一个第二变量值确定第二可执行程序的精度损失是否满足预设条件,若第二可执行程序的精度损失不满足预设条件,暂停执行第一可执行程序和第二可执行程序,接收针对第二可执行程序的第二调试操作,根据第二调试操作对第二可执行程序进行调试,之后返回执行所述通过调试工具基于针对第一可执行程序或第二可执行程序的第一调试操作,调试第一可执行程序和第二可执行程序,如此,通过调试工具同时调试不同精度的两个可执行程序,更加便捷、智能地对第一可执行程序和第二可执行程序的同步调试进行控制,从而实现以更快速的操作对两个不同精度的程序进行调试,无需通过打印、人工查看或者脚本对比,提高调试效率。
应当清楚的是,当第一可执行程序和第二可执行程序是与同一处理器相对应的两个可执行程序,且第一可执行程序和第二可执行程序具有不同的执行精度时,调试工具对这两段可执行程序的精度调试过程与上述实施例的精度调试过程基本一致,具体可参见上文的描述,此处不再赘述。
需要说明的是,对于前述的各方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本披露并不受所描述的动作顺序的限制,因为依据本披露,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于可选实施例,所涉及的动作和模块并不一定是本披露所必须的。
进一步需要说明的是,虽然图2A-图4的流程图中的各个步骤按照箭头的指示依次显示,但是这些步骤并不是必然按照箭头指示的顺序依次执行。除非本文中有明确的说明,这些步骤的执行并没有严格的顺序限制,这些步骤可以以其它的顺序执行。而且,图2A-图4中的至少一部分步骤可以包括多个子步骤或者多个阶段,这些子步骤或者阶段并不必然是在同一时刻执行完成,而是可以在不同的时刻执行,这些子步骤或者阶段的执行顺序也不必然是依次进行,而是可以与其它步骤或者其它步骤的子步骤或者阶段的至少一部分轮流或者交替地执行。
下面介绍本申请提供的程序调试装置。
参见图5,图5是本申请实施例提供的一种程序调试装置的结构示意图,该调试装置可以是GDB等调试工具。该装置500至少可以包括获取单元501和调试单元502,其中,
所述获取单元501,用于获取第一可执行程序和第二可执行程序,其中,所述第一可执行程序与所述第二可执行程序为待调试代码编译后的程序。
所述调试单元502,用于通过调试工具基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序。
在一个可能的实现方式中,所述第一调试操作包括***的检查点;在所述通过调试工具基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序方面,所述调试单元502具体用于:
根据所述第一可执行程序或所述第二可执行程序中对应的第一检查点,获取所述第一可执行程序中的至少一个第一变量值,以及所述第二可执行程序中至少一个第二变量值,所述至少一个第一变量值与所述至少一个第二变量值一一对应,所述第一检查点为针对所述第一可执行程序或所述第二可执行程序中***的检查点;
根据所述至少一个第一变量值和所述至少一个第二变量值确定所述第二可执行程序的运行结果;
当所述第二可执行程序的运行结果不满足预设条件时,则返回执行通过调试工具基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序,直至所述第二可执行程序的运行结果满足所述预设条件。
在一个可能的实现方式中,所述运行结果包括精度损失;所述调试单元502还用于:
若所述第二可执行程序的精度损失不满足预设条件,暂停执行所述第一可执行程序和所述第二可执行程序,之后返回执行所述通过调试工具基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序。
在一个可能的实现方式中,在所述根据所述第一可执行程序或所述第二可执行程序中对应的第一检查点,获取所述第一可执行程序中的至少一个第一变量值,以及所述第二可执行程序中至少一个第二变量值方面,所述调试单元502具体用于:
根据针对所述第一可执行程序中***的第一检查点,获取所述第一可执行程序中的至少一个第一变量值;
根据针对所述第一可执行程序中***的第一检查点以及所述第一可执行程序与所述第二可执行程序的预设关联关系,获取所述第二可执行程序中至少一个第二变量值;或者,
根据所述第一检查点确定针对所述第二可执行程序的第二检查点;根据所述第二检查 点获取所述第二可执行程序中至少一个第二变量值。
在一个可能的实现方式中,在所述根据所述第一可执行程序或所述第二可执行程序中对应的第一检查点,获取所述第一可执行程序中的至少一个第一变量值,以及所述第二可执行程序中至少一个第二变量值方面,所述调试单元502具体用于:
根据针对所述第二可执行程序中***的第一检查点,获取所述第二可执行程序中的至少一个第二变量值;
根据针对所述第二可执行程序中***的第一检查点以及所述第一可执行程序与所述第二可执行程序的预设关联关系,获取所述第一可执行程序中至少一个第一变量值;或者,
根据所述第一检查点确定针对所述第一可执行程序的第二检查点;根据所述第二检查点获取所述第一可执行程序中至少一个第一变量值。
在一个可能的实现方式中,在所述根据所述至少一个第一变量值和所述至少一个第二变量值,确定所述第二可执行程序的运行结果方面,所述调试单元502具体用于:
确定所述至少一个第一变量值中每一第一变量值与对应的第二变量值之间的差值,得到多个差值;
若所述多个差值中存在大于所述预设的误差阈值的差值,确定所述第二可执行程序的精度损失不满足预设条件;
若所述多个差值均小于所述预设的误差阈值的差值,确定所述第二可执行程序的精度损失满足所述预设条件。
在一个可能的实现方式中,所述调试单元502还用于:
在所述第二可执行程序的精度损失满足所述预设条件时,继续执行所述第一可执行程序和所述第二可执行程序。
可以看出,本申请提供的技术方案,计算机设备通过获取待调试代码,根据待调试代码生成通用处理器对应的第一可执行程序,以及根据待调试代码生成人工智能处理器对应的第二可执行程序,通过调试工具基于针对第一可执行程序或第二可执行程序的第一调试操作,调试第一可执行程序和所述第二可执行程序,如此,可通过调试工具同时调试两个可执行程序,从而实现以更快速的操作对两个程序进行调试,无需通过打印、人工查看或者脚本对比,提高调试效率。
应该理解,上述的装置实施例仅是示意性的,本披露的装置还可通过其它的方式实现。例如,上述实施例中所述单元/模块的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。例如,多个单元、模块或组件可以结合,或者可以集成到另一个***,或一些特征可以忽略或不执行。
所述作为分离部件说明的单元或模块可以是物理上分开的,也可以不是物理上分开的。作为单元或模块说明的部件可以是物理单元,也可以不是物理单元,即可以位于一个装置中,或者也可以分布到多个装置上。本披露中实施例的方案可以根据实际的需要选择其中的部分或者全部单元来实现。
本申请实施例还提供了一种调试工具该调试工具能够在CPU等通用处理器上运行以实现相应的调试功能。可选地,该调试工具可以是GDB等调试工具,此处不做具体限定。其中,所述调试工具用于执行如下步骤:
获取第一可执行程序和第二可执行程序,其中,所述第一可执行程序与所述第二可执行程序为待调试代码编译后的程序;
基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序。
可选地,所述第一调试操作包括***的检查点;所述调试工具基于针对所述第一可执 行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序,包括:
根据所述第一可执行程序或所述第二可执行程序中对应的第一检查点,获取所述第一可执行程序中的至少一个第一变量值,以及所述第二可执行程序中至少一个第二变量值,所述至少一个第一变量值与所述至少一个第二变量值一一对应,所述第一检查点为针对所述第一可执行程序或所述第二可执行程序中***的检查点;
根据所述至少一个第一变量值和所述至少一个第二变量值,确定所述第二可执行程序的运行结果;
当所述第二可执行程序的运行结果不满足预设条件时,则返回执行通过调试工具基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序,直至所述第二可执行程序的运行结果满足所述预设条件。
可选地,所述调试工具根据所述第一可执行程序或所述第二可执行程序中对应的第一检查点,获取所述第一可执行程序中的至少一个第一变量值,以及所述第二可执行程序中至少一个第二变量值,包括:
根据针对所述第一可执行程序中***的第一检查点,获取所述第一可执行程序中的至少一个第一变量值;
根据针对所述第一可执行程序中***的第一检查点以及所述第一可执行程序与所述第二可执行程序的预设关联关系,获取所述第二可执行程序中至少一个第二变量值;或者,
根据所述第一检查点确定针对所述第二可执行程序的第二检查点;根据所述第二检查点获取所述第二可执行程序中至少一个第二变量值。
可选地,所述调试工具根据所述第一可执行程序或所述第二可执行程序中对应的第一检查点,获取所述第一可执行程序中的至少一个第一变量值,以及所述第二可执行程序中至少一个第二变量值,包括:
根据针对所述第二可执行程序中***的第一检查点,获取所述第二可执行程序中的至少一个第二变量值;
根据针对所述第二可执行程序中***的第一检查点以及所述第一可执行程序与所述第二可执行程序的预设关联关系,获取所述第一可执行程序中至少一个第一变量值;或者,
根据所述第一检查点确定针对所述第一可执行程序的第二检查点;根据所述第二检查点获取所述第一可执行程序中至少一个第一变量值。
可选地,所述运行结果包括精度损失;所述调试工具还用于:
若所述调试工具确定所述第二可执行程序的精度损失不满足预设条件,暂停执行所述第一可执行程序和所述第二可执行程序,之后返回执行所述基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序。
可选地,所述调试工具根据所述至少一个第一变量值和所述至少一个第二变量值,确定所述第二可执行程序的运行结果,包括:
确定所述至少一个第一变量值中每一第一变量值与对应的第二变量值之间的差值,得到多个差值;
若所述多个差值中存在大于所述预设的误差阈值的差值,确定所述第二可执行程序的精度损失不满足预设条件;
若所述多个差值均小于所述预设的误差阈值的差值,确定所述第二可执行程序的精度损失满足所述预设条件。
可选地,所述调试工具还用于:
若所述第二可执行程序的精度损失满足所述预设条件,继续执行所述第一可执行程序 和所述第二可执行程序。
本申请实施例还提供了一种计算机存储介质,用于存储为上述图2A-图4所示的计算机设备所用的计算机软件指令,其包含用于执行上述方法实施例所涉及的程序。通过执行存储的程序,可以实现上述任一实施例的程序调试方法的步骤。
本申请实施例还提供了一种计算机程序,所述计算机程序包括程序指令,所述程序指令当被处理器执行时使所述处理器执行上述图2A-图4所示的计算机设备所用的计算机软件指令,其包含用于执行上述方法实施例所涉及的程序。通过执行存储的程序,可以实现上述任一实施例的程序调试方法的步骤。
本领域内的技术人员应明白,本申请的实施例可提供为方法、***、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器和光学存储器等)上实施的计算机程序产品的形式。
本申请是参照根据本申请实施例的方法、设备(***)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
本申请实施例中集成的单元/模块如果以硬件的形式实现时,该硬件可以是数字电路,模拟电路等等。硬件结构的物理实现包括但不局限于晶体管,忆阻器等等。若无特别说明,所述人工智能处理器可以是任何适当的硬件处理器,比如CPU、GPU、FPGA、DSP和ASIC等等。若无特别说明,所述存储器可以是任何适当的磁存储介质或者磁光存储介质,比如,阻变式存储器RRAM(Resistive Random Access Memory)、动态随机存取存储器DRAM(Dynamic Random Access Memory)、静态随机存取存储器SRAM(Static Random-Access Memory)、增强动态随机存取存储器EDRAM(Enhanced Dynamic Random Access Memory)、高带宽内存HBM(High-Bandwidth Memory)、混合存储立方HMC(Hybrid Memory Cube)等等。
所述集成的单元/模块如果以软件程序模块的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储器中。基于这样的理解,本披露的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储器中,包括若干指令用以使得一台计算机设备(可为个人计算机、服务器或者网络设备等)执行本披露各个实施例所述方法的全部或部分步骤。而前述的存储器包括:U盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、移动硬盘、磁碟或者光盘等各种可以存储程 序代码的介质。
所述集成的单元/模块如果以软件程序模块的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储器中。基于这样的理解,本披露的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储器中,包括若干指令用以使得一台计算机设备(可为个人计算机、服务器或者网络设备等)执行本披露各个实施例所述方法的全部或部分步骤。而前述的存储器包括:U盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、移动硬盘、磁碟或者光盘等各种可以存储程序代码的介质。
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。上述实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。
进一步地,依据以下条款可更好地理解前述内容:
条款A1,一种程序调试方法,所述方法包括:
获取第一可执行程序和第二可执行程序,其中,所述第一可执行程序与所述第二可执行程序为待调试代码编译后的程序;
基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序。
条款A2、根据A1所述的方法,所述第一调试操作包括***的检查点;基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序,包括:
根据所述第一可执行程序或所述第二可执行程序中对应的第一检查点,获取所述第一可执行程序中的至少一个第一变量值,以及所述第二可执行程序中至少一个第二变量值,所述至少一个第一变量值与所述至少一个第二变量值一一对应,所述第一检查点为针对所述第一可执行程序或所述第二可执行程序中***的检查点;
根据所述至少一个第一变量值和所述至少一个第二变量值,确定所述第二可执行程序的运行结果;
当所述第二可执行程序的运行结果不满足预设条件时,则返回执行通过调试工具基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序,直至所述第二可执行程序的运行结果满足所述预设条件。
条款A3、根据A2所述的方法,所述运行结果包括精度损失;所述方法还包括:
若所述第二可执行程序的精度损失不满足预设条件,暂停执行所述第一可执行程序和所述第二可执行程序,之后返回执行所述通过调试工具基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序。
条款A4、根据A3所述的方法,所述根据所述第一可执行程序或所述第二可执行程序中对应的第一检查点,获取所述第一可执行程序中的至少一个第一变量值,以及所述第二可执行程序中至少一个第二变量值,包括:
根据针对所述第一可执行程序中***的第一检查点,获取所述第一可执行程序中的至少一个第一变量值;
根据针对所述第一可执行程序中***的第一检查点以及所述第一可执行程序与所述第二可执行程序的预设关联关系,获取所述第二可执行程序中至少一个第二变量值;或者,
根据所述第一检查点确定针对所述第二可执行程序的第二检查点;根据所述第二检查 点获取所述第二可执行程序中至少一个第二变量值。
条款A5、根据A3所述的方法,所述根据所述第一可执行程序或所述第二可执行程序中对应的第一检查点,获取所述第一可执行程序中的至少一个第一变量值,以及所述第二可执行程序中至少一个第二变量值,包括:
根据针对所述第二可执行程序中***的第一检查点,获取所述第二可执行程序中的至少一个第二变量值;
根据针对所述第二可执行程序中***的第一检查点以及所述第一可执行程序与所述第二可执行程序的预设关联关系,获取所述第一可执行程序中至少一个第一变量值;或者,
根据所述第一检查点确定针对所述第一可执行程序的第二检查点;根据所述第二检查点获取所述第一可执行程序中至少一个第一变量值。
条款A6、根据A3-A5任一项所述的方法,所述根据所述至少一个第一变量值和所述至少一个第二变量值,确定所述第二可执行程序的运行结果,包括:
确定所述至少一个第一变量值中每一第一变量值与对应的第二变量值之间的差值,得到多个差值;
若所述多个差值中存在大于所述预设的误差阈值的差值,确定所述第二可执行程序的精度损失不满足预设条件;
若所述多个差值均小于所述预设的误差阈值的差值,确定所述第二可执行程序的精度损失满足所述预设条件。
条款A7、根据A4-A6任一项所述的方法,所述方法还包括:
若所述第二可执行程序的精度损失满足所述预设条件,继续执行所述第一可执行程序和所述第二可执行程序。
B1、一种程序调试装置,所述装置包括:
获取单元,用于获取第一可执行程序和第二可执行程序,其中,所述第一可执行程序与所述第二可执行程序为待调试代码编译后的程序;
调试单元,用于通过调试工具基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序。
B2、根据B1所述的装置,所述第一调试操作包括***的检查点;在所述基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序方面,所述调试单元具体用于:
根据所述第一可执行程序或所述第二可执行程序中对应的第一检查点,获取所述第一可执行程序中的至少一个第一变量值,以及所述第二可执行程序中至少一个第二变量值,所述至少一个第一变量值与所述至少一个第二变量值一一对应,所述第一检查点为针对所述第一可执行程序或所述第二可执行程序中***的检查点;
根据所述至少一个第一变量值和所述至少一个第二变量值确定所述第二可执行程序的运行结果;
当所述第二可执行程序的运行结果不满足预设条件时,则返回执行通过调试工具基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序,直至所述第二可执行程序的运行结果满足所述预设条件。
B3、根据B2所述的装置,所述运行结果包括精度损失;所述调试单元还用于:
若所述第二可执行程序的精度损失不满足预设条件,暂停执行所述第一可执行程序和所述第二可执行程序,之后返回执行所述通过调试工具基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序。
B4、根据B3所述的装置,其特征在于,在所述根据所述第一可执行程序或所述第二 可执行程序中对应的第一检查点,获取所述第一可执行程序中的至少一个第一变量值,以及所述第二可执行程序中至少一个第二变量值方面,所述调试单元具体用于:
根据针对所述第一可执行程序中***的第一检查点,获取所述第一可执行程序中的至少一个第一变量值;
根据针对所述第一可执行程序中***的第一检查点以及所述第一可执行程序与所述第二可执行程序的预设关联关系,获取所述第二可执行程序中至少一个第二变量值;或者,
根据所述第一检查点确定针对所述第二可执行程序的第二检查点;根据所述第二检查点获取所述第二可执行程序中至少一个第二变量值。
B5、根据B3所述的装置,在所述根据所述第一可执行程序或所述第二可执行程序中对应的第一检查点,获取所述第一可执行程序中的至少一个第一变量值,以及所述第二可执行程序中至少一个第二变量值方面,所述调试单元具体用于:
根据针对所述第二可执行程序中***的第一检查点,获取所述第二可执行程序中的至少一个第二变量值;
根据针对所述第二可执行程序中***的第一检查点以及所述第一可执行程序与所述第二可执行程序的预设关联关系,获取所述第一可执行程序中至少一个第一变量值;或者,
根据所述第一检查点确定针对所述第一可执行程序的第二检查点;根据所述第二检查点获取所述第一可执行程序中至少一个第一变量值。
B6、根据B3-B5任一项所述的装置,在所述根据所述至少一个第一变量值和所述至少一个第二变量值,确定所述第二可执行程序的运行结果方面,所述调试单元具体用于:
确定所述至少一个第一变量值中每一第一变量值与对应的第二变量值之间的差值,得到多个差值;
若所述多个差值中存在大于所述预设的误差阈值的差值,确定所述第二可执行程序的精度损失不满足预设条件;
若所述多个差值均小于所述预设的误差阈值的差值,确定所述第二可执行程序的精度损失满足所述预设条件。
B7、根据B4-B6任一项所述的装置,所述调试单元还用于:
在所述第二可执行程序的精度损失满足所述预设条件时,继续执行所述第一可执行程序和所述第二可执行程序。
C1、一种计算机设备,其特征在于,包括处理器和存储器,所述处理器和存储器相互连接,其中,所述处理器包括通用处理器和人工智能处理器,所述存储器用于存储计算机程序,所述计算机程序包括程序指令,所述处理器被配置用于调用所述程序指令,执行如权利要求A1-A7任一项所述的方法。
D1、一种计算机可读存储介质,其特征在于,所述计算机存储介质存储有计算机程序,所述计算机程序包括程序指令,所述程序指令当被处理器执行时使所述处理器执行如权利要求A1-A7任一项所述的方法。
以上对本披露实施例进行了详细介绍,本文中应用了具体个例对本披露的原理及实施方式进行了阐述,以上实施例的说明仅用于帮助理解本披露的方法及其核心思想。同时,本领域技术人员依据本披露的思想,基于本披露的具体实施方式及应用范围上做出的改变或变形之处,都属于本披露保护的范围。综上所述,本说明书内容不应理解为对本披露的限制。

Claims (23)

  1. 一种程序调试方法,其特征在于,所述方法包括:
    获取第一可执行程序和第二可执行程序,其中,所述第一可执行程序与所述第二可执行程序为待调试代码编译后的程序;
    基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序。
  2. 根据权利要求1所述的方法,其特征在于,所述第一调试操作包括***的检查点;所述基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序,包括:
    根据所述第一可执行程序或所述第二可执行程序中对应的第一检查点,获取所述第一可执行程序中的至少一个第一变量值,以及所述第二可执行程序中至少一个第二变量值,所述至少一个第一变量值与所述至少一个第二变量值一一对应,所述第一检查点为针对所述第一可执行程序或所述第二可执行程序中***的检查点;
    根据所述至少一个第一变量值和所述至少一个第二变量值,确定所述第二可执行程序的运行结果;
    当所述第二可执行程序的运行结果不满足预设条件时,则返回执行通过调试工具基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序,直至所述第二可执行程序的运行结果满足所述预设条件。
  3. 根据权利要求2所述的方法,其特征在于,所述根据所述第一可执行程序或所述第二可执行程序中对应的第一检查点,获取所述第一可执行程序中的至少一个第一变量值,以及所述第二可执行程序中至少一个第二变量值,包括:
    根据针对所述第一可执行程序中***的第一检查点,获取所述第一可执行程序中的至少一个第一变量值;
    根据针对所述第一可执行程序中***的第一检查点以及所述第一可执行程序与所述第二可执行程序的预设关联关系,获取所述第二可执行程序中至少一个第二变量值;或者,
    根据所述第一检查点确定针对所述第二可执行程序的第二检查点;根据所述第二检查点获取所述第二可执行程序中至少一个第二变量值。
  4. 根据权利要求2所述的方法,其特征在于,所述根据所述第一可执行程序或所述第二可执行程序中对应的第一检查点,获取所述第一可执行程序中的至少一个第一变量值,以及所述第二可执行程序中至少一个第二变量值,包括:
    根据针对所述第二可执行程序中***的第一检查点,获取所述第二可执行程序中的至少一个第二变量值;
    根据针对所述第二可执行程序中***的第一检查点以及所述第一可执行程序与所述第二可执行程序的预设关联关系,获取所述第一可执行程序中至少一个第一变量值;或者,
    根据所述第一检查点确定针对所述第一可执行程序的第二检查点;根据所述第二检查点获取所述第一可执行程序中至少一个第一变量值。
  5. 根据权利要求2-4任一项所述的方法,其特征在于,所述运行结果包括精度损失;所述方法还包括:
    若所述第二可执行程序的精度损失不满足预设条件,暂停执行所述第一可执行程序和所述第二可执行程序,之后返回执行所述基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序。
  6. 根据权利要求5所述的方法,其特征在于,所述根据所述至少一个第一变量值和所 述至少一个第二变量值,确定所述第二可执行程序的运行结果,包括:
    确定所述至少一个第一变量值中每一第一变量值与对应的第二变量值之间的差值,得到多个差值;
    若所述多个差值中存在大于所述预设的误差阈值的差值,确定所述第二可执行程序的精度损失不满足预设条件;
    若所述多个差值均小于所述预设的误差阈值的差值,确定所述第二可执行程序的精度损失满足所述预设条件。
  7. 根据权利要求5所述的方法,其特征在于,所述方法还包括:
    若所述第二可执行程序的精度损失满足所述预设条件,继续执行所述第一可执行程序和所述第二可执行程序。
  8. 一种程序调试装置,其特征在于,所述装置包括:
    获取单元,用于获取第一可执行程序和第二可执行程序,其中,所述第一可执行程序与所述第二可执行程序为待调试代码编译后的程序;
    调试单元,用于基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序。
  9. 根据权利要求8所述的装置,其特征在于,所述第一调试操作包括***的检查点;在所述基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序方面,所述调试单元具体用于:
    根据所述第一可执行程序或所述第二可执行程序中对应的第一检查点,获取所述第一可执行程序中的至少一个第一变量值,以及所述第二可执行程序中至少一个第二变量值,所述至少一个第一变量值与所述至少一个第二变量值一一对应,所述第一检查点为针对所述第一可执行程序或所述第二可执行程序中***的检查点;
    根据所述至少一个第一变量值和所述至少一个第二变量值确定所述第二可执行程序的运行结果;
    当所述第二可执行程序的运行结果不满足预设条件时,则返回执行通过调试工具基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序,直至所述第二可执行程序的运行结果满足所述预设条件。
  10. 根据权利要求9所述的装置,其特征在于,在所述根据所述第一可执行程序或所述第二可执行程序中对应的第一检查点,获取所述第一可执行程序中的至少一个第一变量值,以及所述第二可执行程序中至少一个第二变量值方面,所述调试单元具体用于:
    根据针对所述第一可执行程序中***的第一检查点,获取所述第一可执行程序中的至少一个第一变量值;
    根据针对所述第一可执行程序中***的第一检查点以及所述第一可执行程序与所述第二可执行程序的预设关联关系,获取所述第二可执行程序中至少一个第二变量值;或者,
    根据所述第一检查点确定针对所述第二可执行程序的第二检查点;根据所述第二检查点获取所述第二可执行程序中至少一个第二变量值。
  11. 根据权利要求9所述的装置,其特征在于,在所述根据所述第一可执行程序或所述第二可执行程序中对应的第一检查点,获取所述第一可执行程序中的至少一个第一变量值,以及所述第二可执行程序中至少一个第二变量值方面,所述调试单元具体用于:
    根据针对所述第二可执行程序中***的第一检查点,获取所述第二可执行程序中的至少一个第二变量值;
    根据针对所述第二可执行程序中***的第一检查点以及所述第一可执行程序与所述第二可执行程序的预设关联关系,获取所述第一可执行程序中至少一个第一变量值;或者,
    根据所述第一检查点确定针对所述第一可执行程序的第二检查点;根据所述第二检查点获取所述第一可执行程序中至少一个第一变量值。
  12. 根据权利要求9-11任一项所述的装置,其特征在于,所述运行结果包括精度损失;所述调试单元还用于:
    若所述第二可执行程序的精度损失不满足预设条件,暂停执行所述第一可执行程序和所述第二可执行程序,之后返回执行所述通过调试工具基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序。
  13. 根据权利要求12所述的装置,其特征在于,在所述根据所述至少一个第一变量值和所述至少一个第二变量值,确定所述第二可执行程序的运行结果方面,所述调试单元具体用于:
    确定所述至少一个第一变量值中每一第一变量值与对应的第二变量值之间的差值,得到多个差值;
    若所述多个差值中存在大于所述预设的误差阈值的差值,确定所述第二可执行程序的精度损失不满足预设条件;
    若所述多个差值均小于所述预设的误差阈值的差值,确定所述第二可执行程序的精度损失满足所述预设条件。
  14. 根据权利要求12所述的装置,其特征在于,所述调试单元还用于:
    在所述第二可执行程序的精度损失满足所述预设条件时,继续执行所述第一可执行程序和所述第二可执行程序。
  15. 一种计算机设备,其特征在于,包括处理器和存储器,所述处理器和存储器相互连接,其中,所述存储器用于存储计算机程序,所述计算机程序包括程序指令,所述处理器被配置用于调用所述程序指令,执行如权利要求1-7任一项所述的方法。
  16. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储有计算机程序,所述计算机程序包括程序指令,所述程序指令当被处理器执行时使所述处理器执行如权利要求1-7任一项所述的方法。
  17. 一种调试工具,其特征在于,所述调试工具用于执行如下步骤:
    获取第一可执行程序和第二可执行程序,其中,所述第一可执行程序与所述第二可执行程序为待调试代码编译后的程序;
    基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序。
  18. 根据权利要求17所述的调试工具,其特征在于,所述第一调试操作包括***的检查点;所述调试工具基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序,包括:
    根据所述第一可执行程序或所述第二可执行程序中对应的第一检查点,获取所述第一可执行程序中的至少一个第一变量值,以及所述第二可执行程序中至少一个第二变量值,所述至少一个第一变量值与所述至少一个第二变量值一一对应,所述第一检查点为针对所述第一可执行程序或所述第二可执行程序中***的检查点;
    根据所述至少一个第一变量值和所述至少一个第二变量值,确定所述第二可执行程序的运行结果;
    当所述第二可执行程序的运行结果不满足预设条件时,则返回执行通过调试工具基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序,直至所述第二可执行程序的运行结果满足所述预设条件。
  19. 根据权利要求18所述的调试工具,其特征在于,所述调试工具根据所述第一可执 行程序或所述第二可执行程序中对应的第一检查点,获取所述第一可执行程序中的至少一个第一变量值,以及所述第二可执行程序中至少一个第二变量值,包括:
    根据针对所述第一可执行程序中***的第一检查点,获取所述第一可执行程序中的至少一个第一变量值;
    根据针对所述第一可执行程序中***的第一检查点以及所述第一可执行程序与所述第二可执行程序的预设关联关系,获取所述第二可执行程序中至少一个第二变量值;或者,
    根据所述第一检查点确定针对所述第二可执行程序的第二检查点;根据所述第二检查点获取所述第二可执行程序中至少一个第二变量值。
  20. 根据权利要求18所述的调试工具,其特征在于,所述调试工具根据所述第一可执行程序或所述第二可执行程序中对应的第一检查点,获取所述第一可执行程序中的至少一个第一变量值,以及所述第二可执行程序中至少一个第二变量值,包括:
    根据针对所述第二可执行程序中***的第一检查点,获取所述第二可执行程序中的至少一个第二变量值;
    根据针对所述第二可执行程序中***的第一检查点以及所述第一可执行程序与所述第二可执行程序的预设关联关系,获取所述第一可执行程序中至少一个第一变量值;或者,
    根据所述第一检查点确定针对所述第一可执行程序的第二检查点;根据所述第二检查点获取所述第一可执行程序中至少一个第一变量值。
  21. 根据权利要求18-20任一项所述的调试工具,其特征在于,所述运行结果包括精度损失;所述调试工具还用于:
    若所述调试工具确定所述第二可执行程序的精度损失不满足预设条件,暂停执行所述第一可执行程序和所述第二可执行程序,之后返回执行所述基于针对所述第一可执行程序或所述第二可执行程序的第一调试操作,调试所述第一可执行程序和所述第二可执行程序。
  22. 根据权利要求21所述的调试工具,其特征在于,所述调试工具根据所述至少一个第一变量值和所述至少一个第二变量值,确定所述第二可执行程序的运行结果,包括:
    确定所述至少一个第一变量值中每一第一变量值与对应的第二变量值之间的差值,得到多个差值;
    若所述多个差值中存在大于所述预设的误差阈值的差值,确定所述第二可执行程序的精度损失不满足预设条件;
    若所述多个差值均小于所述预设的误差阈值的差值,确定所述第二可执行程序的精度损失满足所述预设条件。
  23. 根据权利要求21所述的调试工具,其特征在于,所述调试工具还用于:
    若所述第二可执行程序的精度损失满足所述预设条件,继续执行所述第一可执行程序和所述第二可执行程序。
PCT/CN2020/114486 2019-09-12 2020-09-10 程序调试方法、装置、调试工具和计算机设备 WO2021047585A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910869011.6A CN112486799A (zh) 2019-09-12 2019-09-12 程序调试方法、装置和计算机设备
CN201910869011.6 2019-09-12

Publications (1)

Publication Number Publication Date
WO2021047585A1 true WO2021047585A1 (zh) 2021-03-18

Family

ID=74865778

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/114486 WO2021047585A1 (zh) 2019-09-12 2020-09-10 程序调试方法、装置、调试工具和计算机设备

Country Status (2)

Country Link
CN (1) CN112486799A (zh)
WO (1) WO2021047585A1 (zh)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1499363A (zh) * 2002-10-24 2004-05-26 国际商业机器公司 在调试异构体系结构中的集成可执行程序时设置断点的方法和设备
US20080127113A1 (en) * 2006-11-27 2008-05-29 International Business Machines Corporation Method and system for implementing watchpoints
CN101639805A (zh) * 2008-07-31 2010-02-03 国际商业机器公司 用于在程序调试中跟踪变量的方法和设备
CN103473177A (zh) * 2013-09-25 2013-12-25 北京大学 一种在线调试c/c++程序的方法
CN106201896A (zh) * 2016-07-26 2016-12-07 华中科技大学 一种嵌入式环境下基于检查点的调试方法、***及装置
CN109992516A (zh) * 2019-04-03 2019-07-09 北京中科寒武纪科技有限公司 一种编程调试方法、装置及相关产品

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1499363A (zh) * 2002-10-24 2004-05-26 国际商业机器公司 在调试异构体系结构中的集成可执行程序时设置断点的方法和设备
US20080127113A1 (en) * 2006-11-27 2008-05-29 International Business Machines Corporation Method and system for implementing watchpoints
CN101639805A (zh) * 2008-07-31 2010-02-03 国际商业机器公司 用于在程序调试中跟踪变量的方法和设备
CN103473177A (zh) * 2013-09-25 2013-12-25 北京大学 一种在线调试c/c++程序的方法
CN106201896A (zh) * 2016-07-26 2016-12-07 华中科技大学 一种嵌入式环境下基于检查点的调试方法、***及装置
CN109992516A (zh) * 2019-04-03 2019-07-09 北京中科寒武纪科技有限公司 一种编程调试方法、装置及相关产品

Also Published As

Publication number Publication date
CN112486799A (zh) 2021-03-12

Similar Documents

Publication Publication Date Title
US8549468B2 (en) Method, system and computer readable storage device for generating software transaction-level modeling (TLM) model
CN109144515B (zh) Dcs图形化算法组态的离线仿真方法和装置
TWI437390B (zh) 混合模擬系統及方法
US11726899B2 (en) Waveform based reconstruction for emulation
US20160092181A1 (en) Automatic source code generation for accelerated function calls
US20100180263A1 (en) Apparatus and method for detecting software error
US10489534B1 (en) Support for multiple user defined assertion checkers in a multi-FPGA prototyping system
US10061672B2 (en) Implementing random content of program loops in random test generation for processor verification
US11204859B2 (en) Partial-results post-silicon hardware exerciser
US9170919B2 (en) Apparatus and method for detecting location of source code error in mixed-mode program
US20180129578A1 (en) Verifying a graph-based coherency verification tool
WO2020237508A1 (zh) 一种断言验证代码绑定方法及装置
US20160292307A1 (en) Temporal logic robustness guided testing for cyber-physical systems
US9576085B2 (en) Selective importance sampling
US9298858B1 (en) System and method for reducing models based on a criterion
CN106802861A (zh) 一种检测内存泄露的方法和装置
CN103440373A (zh) 一种多dsp***的互联配置模拟方法
Sharma et al. Performance evaluation of real-time systems
WO2021047585A1 (zh) 程序调试方法、装置、调试工具和计算机设备
US9542513B2 (en) Multimode execution of virtual hardware models
WO2018076979A1 (zh) 一种指令间数据依赖的检测方法和装置
US10176276B2 (en) Determining an optimal global quantum for an event-driven simulation
US10816600B1 (en) Protocol analysis and visualization during simulation
WO2023230883A1 (zh) 一种测试方法、***及装置
KR102325612B1 (ko) 시뮬레이터를 구현하는 방법, 장치, 기기 및 매체

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20862221

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20862221

Country of ref document: EP

Kind code of ref document: A1

122 Ep: pct application non-entry in european phase

Ref document number: 20862221

Country of ref document: EP

Kind code of ref document: A1