CN115033497A - Kernel function testing method, device, equipment and storage medium - Google Patents

Kernel function testing method, device, equipment and storage medium Download PDF

Info

Publication number
CN115033497A
CN115033497A CN202210958367.9A CN202210958367A CN115033497A CN 115033497 A CN115033497 A CN 115033497A CN 202210958367 A CN202210958367 A CN 202210958367A CN 115033497 A CN115033497 A CN 115033497A
Authority
CN
China
Prior art keywords
kernel function
data
processing unit
comparison
actual output
Prior art date
Legal status (The legal status 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 status listed.)
Granted
Application number
CN202210958367.9A
Other languages
Chinese (zh)
Other versions
CN115033497B (en
Inventor
姜沛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Chengdu Denglin Technology Co ltd
Beijing Denglin Technology Co ltd
Original Assignee
Chengdu Denglin Technology Co ltd
Beijing Denglin Technology Co ltd
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 Chengdu Denglin Technology Co ltd, Beijing Denglin Technology Co ltd filed Critical Chengdu Denglin Technology Co ltd
Priority to CN202210958367.9A priority Critical patent/CN115033497B/en
Publication of CN115033497A publication Critical patent/CN115033497A/en
Application granted granted Critical
Publication of CN115033497B publication Critical patent/CN115033497B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3692Test management for test results analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory

Abstract

The application provides a kernel function testing method, a kernel function testing device, kernel function testing equipment and a storage medium, and belongs to the technical field of data processing. The method comprises the following steps: obtaining test requirement data corresponding to the kernel function to be tested through the central processing unit according to the configuration file of the kernel function to be tested; triggering the kernel function to execute according to the input data and the resource parameters when the kernel function executes in a thread execution mode through the graphics processor, and obtaining the actual output data of the kernel function; and comparing the actual output data with the comparison data through the central processing unit based on the result comparison mode of the kernel function to obtain the test result of the kernel function. The method and the device are suitable for various kernel functions, and can give consideration to multithreading and multiple times of pressure tests in the test process, so that the robustness of the kernel functions is improved.

Description

Kernel function testing method, device, equipment and storage medium
Technical Field
The present application relates to the field of data processing technologies, and in particular, to a kernel function testing method, apparatus, device, and storage medium.
Background
When a developer tests program data, the developer usually needs to test the code in order to verify whether the written code (for example, a kernel function running in a graphics processor) is correct.
The GPU (Graphics Processor Unit) uses a structural model of SPMD (Single Program Multiple Data), and for a kernel function that can only be executed in the GPU, the GPU has a special use mode, a complex calling process, and is prone to errors in various aspects, and a developer is also prone to errors in the process of compiling the kernel function.
In the prior art, the test of the kernel function generally provides a corresponding test mode for a single specific kernel function, and the universality is low; in addition, in the prior art, in the process of testing the kernel function, the hidden problem is difficult to find, so that the robustness of the kernel function is poor.
Disclosure of Invention
The application aims to provide a kernel function testing method, a kernel function testing device, kernel function testing equipment and a kernel function testing storage medium, which can be suitable for various kernel functions, can give consideration to multithreading and multi-frequency pressure testing in the testing process, and improve the robustness of the kernel function.
The embodiment of the application is realized as follows:
in one aspect of the embodiments of the present application, a kernel function testing method is provided, including:
obtaining test requirement data corresponding to the kernel function to be tested through the central processing unit according to the configuration file of the kernel function to be tested, wherein the test requirement data comprises: the method comprises the following steps of inputting data of a kernel function, comparison data of the kernel function, a result comparison mode of the kernel function, resource parameters during kernel function execution, and a thread execution mode, wherein the thread execution mode is used for indicating the number of threads of a plurality of threads related to the kernel function and the execution times of each thread;
triggering the kernel function to execute according to the input data and the resource parameters when the kernel function executes in a thread execution mode through the graphics processor, and obtaining the actual output data of the kernel function;
and comparing the actual output data with the comparison data through the central processing unit based on the result comparison mode of the kernel function to obtain the test result of the kernel function.
Optionally, obtaining, by the central processing unit, test requirement data corresponding to the kernel function to be tested according to the configuration file of the kernel function to be tested, where the test requirement data includes: reading the position of an input data file of the kernel function, the position of a comparison data file of the kernel function, a result comparison mode of the kernel function, resource parameters when the kernel function is executed, the number of threads and the execution times of each thread from the configuration file; determining a thread execution mode according to the number of threads and the execution times of each thread; and reading the input data according to the position of the input data file through the central processing unit, and reading the comparison data according to the position of the comparison data file.
Optionally, the test requirement data further includes: allocating data in a memory; after obtaining the test requirement data corresponding to the kernel function to be tested, the method further comprises: acquiring memory allocation data from a central processing unit, and determining a first memory allocation result of data input in the central processing unit according to the memory allocation data; synchronizing input data for memory allocation according to the first memory allocation result to the graphics processor;
triggering the kernel function to execute according to the input data and the resource parameters when the kernel function executes in a thread execution mode through the graphics processor to obtain the actual output data of the kernel function, wherein the method comprises the following steps: and triggering the kernel function to execute according to the input data of the memory allocation performed by the first memory allocation result and the resource parameters during the execution of the kernel function by the graphics processor in a thread execution mode to obtain the actual output data of the kernel function.
Optionally, before the actual output data is compared with the comparison data by the central processing unit based on the result comparison mode of the kernel function to obtain the test result of the kernel function, the method further includes: determining a second memory allocation result of the actual output data obtained from the graphics processor; synchronizing actual output data of the memory allocation performed by the second memory allocation result to the central processing unit;
based on the result comparison mode of the kernel function, comparing the actual output data with the comparison data through the central processing unit to obtain the test result of the kernel function, wherein the test result comprises the following steps: and comparing the actual output data of the memory allocation performed by the second memory allocation result with the comparison data by the central processing unit based on the result comparison mode of the kernel function to obtain the test result of the kernel function.
Optionally, based on a result comparison manner of the kernel function, comparing the actual output data with the comparison data by the central processing unit to obtain a test result of the kernel function, where the method includes: comparing the subdata at each position in the actual output data with the subdata at each corresponding position in the comparison data in sequence by the central processing unit; if the subdata at one position in the actual output data is different from the subdata at the corresponding position in the comparison data, determining that an error exists in the test result; and if the subdata at all the positions in the actual output data is the same as the subdata at all the corresponding positions in the comparison data, determining that no error exists in the test result.
Optionally, based on the result comparison mode of the kernel function, comparing the actual output data with the comparison data by the central processing unit to obtain the test result of the kernel function, including: comparing a first set formed by all subdata in the actual output data with a second set formed by all subdata in the comparison data through a central processing unit; if the subdata in the first set is different from the subdata in the second set, determining that an error exists in a test result; and if the subdata in the first set is the same as the subdata in the second set, determining that no error exists in the test result.
Optionally, before the actual output data is compared with the comparison data by the central processing unit based on the result comparison mode of the kernel function to obtain the test result of the kernel function, the method further includes:
and determining the number of the actual output data and performing data registration processing according to the number of the actual output data.
In another aspect of the embodiments of the present application, there is provided a kernel function testing apparatus, including: the device comprises an acquisition module, an execution module and a comparison module;
the obtaining module is used for obtaining test requirement data corresponding to the kernel function to be tested according to the configuration file of the kernel function to be tested through the central processing unit, and the test requirement data comprises: the method comprises the following steps of inputting data of a kernel function, comparison data of the kernel function, a result comparison mode of the kernel function, resource parameters during kernel function execution, and a thread execution mode, wherein the thread execution mode is used for indicating the number of threads of a plurality of threads related to the kernel function and the execution times of each thread;
the execution module is used for triggering the kernel function to execute according to the input data and the resource parameters during the execution of the kernel function in a thread execution mode through the graphics processor to obtain the actual output data of the kernel function;
and the comparison module is used for comparing the actual output data with the comparison data through the central processing unit based on the result comparison mode of the kernel function to obtain the test result of the kernel function.
In another aspect of the embodiments of the present application, there is provided a computer device, including: the device comprises a memory, a central processing unit and a graphic processor, wherein the memory, the central processing unit and the graphic processor are connected through a bus, a computer program which can run on the central processing unit and the graphic processor is stored in the memory, and the central processing unit and the graphic processor are used for realizing the test method of the kernel function.
In another aspect of the embodiments of the present application, a computer-readable storage medium is provided, where a computer program is stored on the storage medium, and when the computer program is executed by a processor, the computer program implements the steps of the kernel function testing method.
The beneficial effects of the embodiment of the application include:
in the kernel function testing method, device, equipment and storage medium provided by the embodiment of the application, the testing requirement data corresponding to the kernel function to be tested can be obtained through the central processing unit according to the configuration file of the kernel function to be tested; triggering the kernel function to execute according to the input data and the resource parameters during the execution of the kernel function in a thread execution mode through a graphic processor to obtain the actual output data of the kernel function; and comparing the actual output data with the comparison data through the central processing unit based on the result comparison mode of the kernel function to obtain the test result of the kernel function. Various data required to be used in the test process can be obtained through the configuration file of the kernel function, so that the test on various kernel functions can be met, and the test universality is improved; in addition, in the testing process, the testing can be carried out according to a thread execution mode, and multithreading and multi-time pressure testing can be considered in the testing process, so that the testing process can be normally executed, the hidden problem of the kernel function in the testing process is found, and the robustness of the kernel function is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained from the drawings without inventive effort.
Fig. 1 is a schematic diagram of a program architecture corresponding to a kernel function testing method according to an embodiment of the present disclosure;
fig. 2 is a schematic flowchart of a kernel function testing method according to an embodiment of the present application;
fig. 3 is another schematic flowchart of a kernel function testing method according to an embodiment of the present application;
fig. 4 is a schematic flowchart illustrating comparison of results in the kernel function testing method according to the embodiment of the present application;
fig. 5 is another schematic flow chart illustrating result comparison in the kernel function testing method according to the embodiment of the present application;
fig. 6 is a schematic flowchart of a kernel function testing method according to an embodiment of the present application;
fig. 7 is a schematic diagram illustrating a specific flow of memory allocation in a kernel function testing method according to an embodiment of the present application;
fig. 8 is another schematic flow chart illustrating memory allocation in the kernel function testing method according to the embodiment of the present disclosure;
fig. 9 is a schematic structural diagram of a kernel function testing apparatus according to an embodiment of the present application;
fig. 10 is a schematic mechanism diagram of a computer device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. The components of the embodiments of the present application, generally described and illustrated in the figures herein, can be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the present application, presented in the accompanying drawings, is not intended to limit the scope of the claimed application, but is merely representative of selected embodiments of the application. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined or explained in subsequent figures.
In the description of the present application, it is noted that the terms "first", "second", "third", and the like are used merely for distinguishing between descriptions and are not intended to indicate or imply relative importance.
Kernel functions (Kernel) may specifically refer to functions that are executed in a Graphics Processor (GPU), and Kernel functions may be executed only in the GPU and may not be executed in a Central Processing Unit (CPU).
In the actual processing process, the central processing unit may call the kernel function according to a certain logic rule, and in the calling process, related parameters are usually required to be configured, and data to be processed is also required to be sent to the graphics processing unit from the central processing unit for execution, and is returned to the central processing unit after the graphics processing unit obtains an execution result. In addition, in the above implementation process, the developer needs to actively participate in a series of tasks, such as: and performing work such as memory allocation and data management.
Because the Kernel function is specially used, the calling process of the Kernel function is complex, and therefore, no matter the Kernel function is an experienced research and development worker or a beginner, errors are easy to make when the Kernel function-carrying related codes are compiled, and random errors may occur.
In the prior art, when checking whether a Kernel function has an error, a specific test mode is usually adopted for a certain Kernel function or a certain class of Kernel functions, for example, a test mode is executed for Kernel-a type of Kernel functions; however, other types of Kernel functions, such as Kernel function Kernel-B, cannot be tested directly in the Kernel-a test mode, that is, the test mode adopted in the prior art is usually a test for a specific Kernel function or a certain Kernel function, and the universality is low.
Moreover, for a certain kernel function, when testing is performed, the factors such as the number of threads existing in the kernel function during execution and the number of times of execution of each thread are not considered, so that the hidden problem existing in the kernel function during execution is easily ignored, the test result is not necessarily accurate, and some errors and random errors may exist, so that the accuracy of the test result is reduced, and the test result is more one-sided.
In view of this, the embodiments of the present application provide a kernel function testing method, which may be applicable to testing of various kernel functions, has high versatility, and may give consideration to multithreading and multiple times of pressure tests on a large scale, so as to be beneficial to quickly detecting some hidden random problems. The program architecture corresponding to the method is specifically explained below.
Fig. 1 is a schematic diagram of a program architecture corresponding to a kernel function testing method according to an embodiment of the present application, please refer to fig. 1, the architecture may include three layers: the uppermost parsing layer 110, the middle testing layer 120 (which may be referred to as "KernelTester"), and the lowermost execution layer, wherein the execution layers may include: kernel function execution unit 131 (which may be referred to as "KernelRunner"), compare unit 132 (which may be referred to as "Checker"), and memory allocation unit 133 (which may be referred to as "tester").
The parsing layer 110 may be a layer for parsing configuration files of any format, and supports parsing configuration files of multiple format types. For example: a Json (JavaScript Object Notation) parsing layer, which can parse the Json-formatted file; or a parsing layer that can also parse other types of files, such as: JS format (JavaScript, transliterated script language format), etc., and is not particularly limited herein. After the parsing layer 110 parses the configuration file, the obtained parsing result may be transmitted to the testing layer 120.
The test layer 120 may implement a general planning in the test process, and may transmit the obtained related data to the corresponding execution layer for execution. In addition to receiving the parsing result provided by the parsing layer 110, the testing layer 120 may also perform data copying according to the content of the parsing result, so as to read the data to be processed and the comparison data (golden data) for verification comparison in advance; according to the content of the parsing result, some functional units (e.g. kernel function execution unit 131, comparison unit 132, and memory allocation unit 133) may be registered, configured, or started, and the tasks in the kernel function test process are executed by these functional units.
The execution layer may specifically accomplish one or more tasks in the testing process, such as: the kernel function execution unit 131 may establish a test condition required for the test and execute the kernel function under the test condition to perform the test; the comparison unit 132 may compare the data output for the test with the pre-stored comparison data, providing a verification function; the memory allocation unit 133 provides a data management function, and may allocate buffers (buffers) to different objects at different links, and perform data caching based on the allocated buffers. For example, before the GPU executes the kernel, the memory of the GPU is subjected to buffer allocation and management, and after the GPU executes the kernel, the memory of the central processing unit is subjected to buffer allocation and management, so that the memory management and allocation by a user manually are avoided, and a developer is not required to temporarily perform memory allocation and data management in a test process.
It should be noted that the above-described architecture is an architecture on a software program, does not have a physical structure, and is implemented based on a computer language.
The following explains a specific implementation process of the kernel function testing method provided in the embodiment of the present application based on the above program architecture.
Fig. 2 is a schematic flowchart of a kernel function testing method according to an embodiment of the present application, please refer to fig. 2, where the kernel function testing method includes:
s210: and obtaining test requirement data corresponding to the kernel function to be tested through the central processing unit according to the configuration file of the kernel function to be tested.
Wherein the test demand data includes: input data of the kernel function, comparison data of the kernel function, a result comparison mode of the kernel function, resource parameters when the kernel function is executed and a thread execution mode. The thread execution mode is used for indicating the number of threads of a plurality of threads related to the kernel function and the execution times of each thread.
Optionally, an execution subject of the method may specifically be a computer device, and the computer device may be provided with the program of the kernel function testing method, and specifically may implement the method based on the program. The computer device may also include a central processor and a graphics processor.
The step S210 may be specifically completed by the parsing layer, and the configuration file of the kernel function to be tested may be specifically a file in a Json format. The analysis layer can analyze the configuration file to obtain the test requirement data.
Specifically, the input data of the kernel function may be input data, that is, input data when the kernel function is executed, and the number of the input data, the type, the size dimension, the position, and the like of each input data may be obtained.
The comparison data of the kernel function may be gold data, that is, correct data that the kernel function should output after the kernel function completes executing, and the data may be stored as the comparison data for subsequent comparison of the output data that is actually executed.
The result comparison method of the kernel function may be a comparison method of comparing the actual output data with the comparison data after the kernel function is executed to obtain the actual output data.
The resource parameter when the kernel function executes may be a related parameter used by the kernel function in the execution process and the transmission process, for example: a thread grid parameter (grid), a thread block parameter (block), a shared memory parameter (share memory size), and the like.
The thread execution mode may be the number of threads of a plurality of threads related to the kernel function and the number of times each thread is executed, for example: the number M of times that the kernel function is executed in each thread may be indicated, and the process implemented by the threads during execution is the thread execution mode.
The kernel function to be tested can complete a stress test based on the thread execution mode, thereby exposing more hidden problems and exposing some random problems.
S220: and triggering the kernel function to execute according to the input data and the resource parameters during the execution of the kernel function by using a thread execution mode through the graphics processor, so as to obtain the actual output data of the kernel function.
Optionally, after obtaining the test requirement data, a test may be performed, and the execution process may be specifically completed by a kernel function execution unit in the execution layer.
After the central processing unit obtains the test requirement data, the data required to be used in the execution process can be sent to the graphic processor, and the specific implementation process can be to copy the relevant data from the central processing unit to the graphic processor. After the graphics processor receives the relevant data, the graphics processor can trigger the kernel function to execute in a thread execution mode according to the input data and the resource parameters of the kernel function during execution, so as to obtain the actual output data of the kernel function.
It should be noted that before executing the test, the kernel function execution unit may also establish the test conditions required in the test process, for example: the kernel function may be compiled into a file in the fastbin format, and may be loaded from the file in the fastbin format by a relevant function such as module, CUfunction, etc. in a manner of RTC (Runtime Compilation), and various configuration parameters, etc. for kernel function execution, such as block dims, GridDims, Shared _ mem _ bytes, etc. may also be configured. After the configuration, it may be determined that a condition for executing the test is satisfied, and the kernel function executing unit may execute the kernel function based on the established test condition and complete the test, to obtain the actual output data after the test.
It should be noted that, when the kernel function execution unit executes the kernel function, the kernel function execution unit executes the kernel function in the test layer in the program framework, the kernel function is executed once in only one thread, the kernel function execution unit is only responsible for correctly completing the execution of the kernel function once, and the multithreading and the number of times required by the actual test are configured and completed by the test layer in an overall manner.
S230: and comparing the actual output data with the comparison data through the central processing unit based on the result comparison mode of the kernel function to obtain the test result of the kernel function.
Optionally, after the graphics processor performs the test and obtains the actual output data, the actual output data may be sent to the central processing unit, and the specific implementation process may be to copy the actual output data from the graphics processor to the central processing unit. The comparison process may be specifically implemented by a comparison unit in the execution layer, and the copy process may be implemented by a memory allocation unit.
After the central processing unit receives the actual output data, it can be compared with the comparison data previously stored in the central processing unit. Since the comparison data is correct output data, whether the actual output data is correct or not can be determined by comparing the actual output data with the comparison data, so that a corresponding test result is obtained.
It should be noted that the test result may specifically be that there is an error or there is no error in the kernel function, and in some cases, the test result may reflect a location where there is an error.
In summary, for example: if the Kernel function of Kernel-A needs to be tested, testing requirement data corresponding to Kernel-A can be obtained through a central processing unit according to a configuration file of Kernel-A; and triggering the Kernel-A to execute according to the input data and the resource parameters when the Kernel-A executes in a thread execution mode through the graphic processor, obtaining the actual output data of the Kernel-A under the test condition, and comparing the actual output data of the Kernel-A with the corresponding comparison data of the Kernel-A through the central processing unit based on a result comparison mode of the Kernel-A after obtaining the actual output data to obtain the test result of the Kernel-A. When the Kernel function of the Kernel-B needs to be tested, the test requirement data of the Kernel-B can be obtained by reading the configuration file of the Kernel-B, the corresponding thread execution mode is determined based on the content specified in the test requirement data of the Kernel-B, the test condition is established for the Kernel-B, the parameter configuration is carried out, the Kernel-B is executed according to the determined thread execution mode and the established test condition, the actual output data of the Kernel-B under the test condition is obtained, and the actual output data of the Kernel-B is compared with the comparison data corresponding to the Kernel-B, so that the test result of the Kernel-B is obtained. The process can be suitable for testing various types of kernel functions, has high universality, can give consideration to multithreading and multi-time pressure testing, and exposes more hidden random problems.
In the kernel function testing method provided by the embodiment of the application, testing requirement data corresponding to the kernel function to be tested can be obtained through the central processing unit according to the configuration file of the kernel function to be tested; triggering the kernel function to execute according to the input data and the resource parameters when the kernel function executes in a thread execution mode through the graphics processor, and obtaining the actual output data of the kernel function; and comparing the actual output data with the comparison data through the central processing unit based on the result comparison mode of the kernel function to obtain the test result of the kernel function. Various data required to be used in the test process can be obtained through the configuration file of the kernel function, so that the test on various types of kernel functions can be met, and the test universality is improved; in addition, in the testing process, the testing can be carried out according to a thread execution mode, and multithreading and multi-time pressure testing can be considered in the testing process, so that the testing process can be normally executed, the hidden problem of the kernel function in the testing process is found, and the robustness of the kernel function is improved.
A specific implementation process of obtaining test requirement data corresponding to a kernel function to be tested in the kernel function test method provided in the embodiment of the present application is specifically explained below.
Fig. 3 is another schematic flow chart of the kernel function testing method according to the embodiment of the present application, please refer to fig. 3, where the method includes obtaining, by the central processing unit, test requirement data corresponding to the kernel function to be tested according to the configuration file of the kernel function to be tested, and the method includes:
s310: and reading the position of an input data file of the kernel function, the position of a comparison data file of the kernel function, a result comparison mode of the kernel function, resource parameters when the kernel function is executed, the number of threads and the execution times of each thread from the configuration file.
Optionally, the configuration file of the kernel function may include the following three types of data: the function data (Kernel data), the comparison data (Checker data), and the memory allocation data (in _ tens data and out _ tens data, which may reflect data types, data sources, tensor dimension information of data, etc.).
For example, the position of the input data file of the Kernel function, the position of the comparison data file of the Kernel function, the resource parameters when the Kernel function is executed, the number of threads, and the execution times of each thread may be parsed and read from the Kernel data; the result comparison of the kernel function can be parsed and read from the Checker data.
After the data are analyzed and read, the data can be further processed to obtain test requirement data, and the specific process is as follows:
s320: and determining the thread execution mode according to the number of the threads and the execution times of each thread.
The thread execution mode in the test requirement data can be obtained based on the number of the read threads and the execution times of each thread.
Different thread execution modes may be provided for different numbers of threads and execution times of each thread, and the specific determined process may be set according to actual execution requirements, which is not limited herein.
S330: and reading the input data according to the position of the input data file and reading the comparison data according to the position of the comparison data file by the central processing unit.
It should be noted that the two steps of S320 and S330 may be executed separately or sequentially, and there is no necessary requirement for the execution order in the actual execution process, and the two steps are explained as an example in fig. 3.
Optionally, after the position of the input data file of the kernel function and the position of the comparison data file of the kernel function are read from the configuration file, the input data and the comparison data may be obtained by reading and storing the positions by the central processing unit.
For input data, the central processing unit can provide the input data for the graphic processor to execute testing after obtaining the input data; the comparison data may be stored in the central processing unit, specifically, in a register of the central processing unit, for the subsequent comparison process.
In the kernel function testing method provided by the embodiment of the application, the position of an input data file of a kernel function, the position of a comparison data file of the kernel function, a result comparison mode of the kernel function, resource parameters during execution of the kernel function, the number of threads and the execution times of each thread can be read from a configuration file; determining a thread execution mode according to the number of threads and the execution times of each thread; and reading the input data according to the position of the input data file and reading the comparison data according to the position of the comparison data file by the central processing unit. The configuration file is read and analyzed in the mode, more comprehensive test requirement data can be obtained, then the test is carried out based on the more comprehensive test requirement data, the test of any type of kernel function can be met, and the test universality is improved.
Optionally, after obtaining test requirement data corresponding to the kernel function to be tested, the method further includes: and sending the input data, the resource parameters and the thread execution mode to the graphic processor through the central processing unit.
After obtaining the test requirement data, the central processing unit may send data to be used in the test process to the graphics processor, which may specifically include the input data, the resource parameters, and the thread execution mode. After receiving the input data, the resource parameters, and the thread execution mode, the graphics processor may store the data in a video memory of the graphics processor, and may execute a test on the kernel function based on the input data, the resource parameters, and the thread execution mode.
The following specifically explains a specific implementation process of obtaining a test result of a kernel function in the kernel function test method provided in the embodiment of the present application.
Fig. 4 is a schematic flow chart illustrating result comparison performed in the kernel function testing method according to the embodiment of the present application, please refer to fig. 4, where the actual output data is compared with the comparison data by the central processing unit based on the result comparison manner of the kernel function, so as to obtain the testing result of the kernel function, where the method includes:
s410: and comparing the subdata at each position in the actual output data with the subdata at each corresponding position in the comparison data in sequence through the central processing unit.
Alternatively, the comparison process may be specifically implemented by a central processing unit, and may be specifically completed by a comparison unit of an execution layer in the program architecture.
A plurality of ordered subdata may exist in actual output data obtained after the test is executed; correspondingly, the comparison data also has a plurality of ordered subdata, and the subdata at each position in the actual output data and the subdata at the corresponding position in the comparison data can be sequentially compared. The corresponding test result may be determined based on the comparison, which may specifically include the following two cases:
s420: and if the subdata at one position in the actual output data is different from the subdata at the corresponding position in the comparison data, determining that the test result is an error.
Optionally, if the sub data in the corresponding position are different, it may be determined that the test result has an error.
It should be noted that, because a plurality of subdata exist in the actual output data, the subdata in any position may be different, and the test result may be considered as an error.
S430: and if the subdata at all the positions in the actual output data is the same as the subdata at all the corresponding positions in the comparison data, determining that no error exists in the test result.
Optionally, if the subdata at each corresponding position is the same, that is, the actual output data is completely the same as the comparison data (that is, the data content itself is the same, and the sequence or the position of each subdata is the same), it may be determined that there is no error in the test result.
In the kernel function testing method provided by the embodiment of the application, the subdata at each position in the actual output data can be sequentially compared with the subdata at each corresponding position in the comparison data one by one through the central processing unit; if the subdata at any position in the actual output data is different from the subdata at the corresponding position in the comparison data, determining that an error exists in the test result; and if the subdata at each position in the actual output data is the same as the subdata at the corresponding position in the comparison data, determining that no error exists in the test result. The sub data at each position are compared in sequence, so that the position with the error can be determined more accurately, further, whether the error exists in the test result can be determined, the corresponding error position can be obtained quickly under the condition that the error exists, and a developer can check and adjust the written program of the kernel function conveniently.
Another specific implementation process for obtaining the test result of the kernel function in the kernel function test method provided in the embodiment of the present application is specifically explained below.
Fig. 5 is another schematic flow chart illustrating result comparison in the kernel function testing method according to the embodiment of the present application, please refer to fig. 5, in which the actual output data is compared with the comparison data by the central processing unit based on the result comparison manner of the kernel function, so as to obtain the testing result of the kernel function, and the method includes:
s510: and comparing the first set of all subdata in the actual output data with the second set of all subdata in the comparison data by the central processing unit.
A plurality of subdata may exist in actual output data obtained after the test is executed, and the subdata may form a set, wherein the set is the first set; correspondingly, there are also a plurality of subdata in the comparison data, and these subdata may also form a set, which may be used as a second set, and may be compared with the second set of the comparison data based on the first set of the actual output data. The corresponding test result may be determined based on the comparison, which may specifically include the following two cases:
s520: and if the sub-data in the first set and the sub-data in the second set are different in type, determining that the test result is error.
Optionally, it may be determined whether the first set includes all the sub data in the second set, and whether the second set includes all the sub data in the first set, and if any of the above two conditions is not satisfied, it may be determined that the sub data in the first set and the sub data in the second set are different in type. Accordingly, it may be determined that the test result is an error.
S530: and if the types of the subdata in the first set and the subdata in the second set are the same, determining that no error exists in the test result.
Optionally, if it is determined that the first set includes all the sub-data in the second set, and the second set includes all the sub-data in the first set, that is, the type of the sub-data in the first set is the same as the type of the sub-data in the second set, it may be determined that the first set is the same as the second set, and it may be determined that the test result is error-free.
It should be noted that the comparison method of S510-530 does not need to pay attention to the location of the child data in the compared set, and in one example, if: the subdata in the first set exists in the second set, and the subdata in the second set exists in the first set, so that the test result is considered to have no error.
In the kernel function testing method provided by the embodiment of the application, a first set composed of all subdata in actual output data and a second set composed of all subdata in comparison data can be compared through a central processing unit; if the types of the subdata in the first set and the subdata in the second set are different, determining that the test result is error; and if the types of the subdata in the first set and the subdata in the second set are the same, determining that no error exists in the test result. And comparing whether the first set and the second set are completely the same or not, so that the test result can be obtained more quickly, and the efficiency of obtaining the test result is improved.
Optionally, the steps S410 to S430 and the steps S510 to S530 may be two ways of obtaining the test result, and one of the ways may be selected to be implemented in the actual implementation process, and specifically, the implementation mode meeting the actual requirement may be selected according to the actual requirement to complete the determination of the test result.
Alternatively, the actual output data obtained may also be different based on different kernel functions, the above is only the determination of the test result implemented for the mode in which there is one output data (one output data may include a plurality of sub data), and if there are a plurality of output data, the comparing unit may perform the comparison by using the following two sub units.
Result comparison subunit (ResultChecker): the same comparison (either of S410-S430 or S510-S530 described above) may be used for each output data to obtain the test result.
Single comparator subunit (TensorChecker): different comparison modes can be adopted for each output data, one comparison mode can be set for each output data, and a plurality of single comparison subunits can be registered from a test layer in a program framework in the actual implementation process, so that comparison of a plurality of actual output data is realized.
Optionally, before the actual output data is compared with the comparison data by the central processing unit based on the result comparison mode of the kernel function to obtain the test result of the kernel function, the method further includes: and determining the number of the actual output data and performing data registration processing according to the number of the actual output data.
Wherein the data registration process may be a process of registering the child unit in the comparison unit. Specifically, after the actual output data is obtained, a corresponding number of sub units may be registered from the comparison unit based on the number of actual output data. Each registered subunit may be responsible for comparing and verifying a portion of the actual output data.
For example: if a single comparison subunit is used for comparison, and there are 10 actual output data, 10 single comparison subunits can be registered in the comparison unit.
Another specific implementation process of the kernel function test method provided in the embodiment of the present application is explained below.
Fig. 6 is a schematic flow chart of a kernel function testing method according to an embodiment of the present disclosure, please refer to fig. 6, where before comparing actual output data with comparison data by a central processing unit based on a kernel function result comparing manner to obtain a kernel function testing result, the method includes:
s610: and judging whether the actual output data is normal or not.
Optionally, after obtaining the actual output data, the graphics processor may determine whether the actual output data is normal, specifically, determine whether the test is normally executed, and if the test is normally executed, determine that the actual output data is normal; accordingly, if the test execution is abnormal, it may be determined that the actual output data is abnormal.
If yes, S620: and sending the actual output data to a central processing unit by the graphic processor.
If the actual output data is normal, the identification of the actual output data can be marked as a correct identification (True), and the actual output data can be sent to a central processing unit from the graphic processor for subsequent comparison work; accordingly, if not normal, the output may be waited for to be normal or the foregoing steps may be re-performed to make the output normal.
Next, another specific implementation process of the kernel function testing method provided in the embodiment of the present application is explained.
Fig. 7 is a schematic diagram illustrating a specific process of performing memory allocation in a kernel function testing method according to an embodiment of the present application, please refer to fig. 7, where the test requirement data further includes: allocating data in a memory; after obtaining the test requirement data corresponding to the kernel function to be tested, the method further comprises:
s710: the method comprises the steps of obtaining memory allocation data from a central processing unit, and determining a first memory allocation result of data input into the central processing unit according to the memory allocation data.
It should be noted that the memory allocation data may be data read from and parsed from a configuration file of the kernel function, that is, the memory allocation data (in _ sensors data and out _ sensors data). The process may specifically be implemented by a memory allocation unit in the execution layer.
Optionally, the memory allocation unit is a memory allocation unit 133 (which may be referred to as "sensor") in the execution layer in fig. 1, and the memory allocation unit may determine a first memory allocation result of data input in the central processing unit according to the memory allocation data, where the first memory allocation result may be a memory allocation ratio of the data input in the central processing unit, and if the input data includes a plurality of input data, the memory allocation ratio of each input data may be recorded, for example: for the input data X, the corresponding first memory allocation result may be a memory X occupying a certain position, and the size of the memory X is a preset value.
S720: and synchronizing the input data subjected to memory allocation according to the first memory allocation result to the graphics processor.
Optionally, the memory allocation unit may implement transmission of memory information, and in a process of implementing transmission of input data in the central processing unit to the graphics processor, input data allocated with the first memory allocation result may be synchronized to the graphics processor, that is, when the input data is transmitted, a memory allocation ratio of the input data is not changed and is the same as a memory allocation ratio in the central processing unit.
Based on S720, in S220, triggering the kernel function to execute according to the input data and the resource parameter when the kernel function executes in a thread execution manner by the graphics processor, and obtaining the actual output data of the kernel function, the method may include:
s730: and triggering the kernel function to execute by the graphics processor in a thread execution mode according to the input data for performing memory allocation by using the first memory allocation result and the resource parameters during the execution of the kernel function, so as to obtain the actual output data of the kernel function.
Optionally, in the calculation process of calculating the actual output data by executing the kernel function, the kernel function may be triggered to execute based on the input data for performing memory allocation according to the first memory allocation result and the resource parameter when the kernel function executes.
If a plurality of input data exist, each input data can be processed in sequence, and each input data can be subjected to memory allocation according to the first memory allocation result.
In the kernel function testing method provided by the embodiment of the application, memory allocation data can be acquired from a central processing unit through a memory allocation unit, and a first memory allocation result of data input in the central processing unit is determined according to the memory allocation data; synchronizing input data subjected to memory allocation according to the first memory allocation result to the graphics processor through a memory allocation unit; and triggering the kernel function to execute according to the input data of the memory allocation performed by the first memory allocation result and the resource parameters during the execution of the kernel function by the graphics processor in a thread execution mode to obtain the actual output data of the kernel function. The memory allocation unit can realize the memory allocation of the input data and the transmission of the input data, and can keep the memory allocation ratio of the input data unchanged in the process of transmitting the data from the central processing unit to the graphic processor, thereby more accurately and quickly realizing the determination of the memory allocation ratio of the input data in the graphic processor and more quickly realizing the memory allocation and copy management in the kernel function test process.
Next, a further specific implementation process of the kernel function testing method provided in the embodiment of the present application is explained.
Fig. 8 is another schematic flow chart illustrating memory allocation in the kernel function testing method according to the embodiment of the present application, please refer to fig. 8, where before the actual output data is compared with the comparison data by the central processing unit based on the result comparison manner of the kernel function to obtain the testing result of the kernel function, the method further includes:
s810: determining a second memory allocation result of the actual output data obtained in the graphics processor.
Alternatively, the second memory allocation result may be a memory allocation ratio of actual output data in the graphics processor. This process may also be performed by the memory allocation unit.
S820: and synchronizing the actual output data of the memory allocation performed by the second memory allocation result to the central processing unit.
Optionally, the memory allocation unit may implement transmission of memory information, and in the process of implementing transmission of the actual output data in the graphics processor to the central processing unit, may synchronize the actual output data, which is allocated by using the second memory allocation result, to the central processing unit, that is, when the actual output data is transmitted, the memory allocation duty ratio of the actual output data is not changed, and is the same as the memory allocation duty ratio in the graphics processor.
Based on the result comparison method based on the kernel function in S820 and S230, the comparing the actual output data with the comparison data by the central processing unit to obtain the test result of the kernel function may include:
s830: and comparing the actual output data of the memory allocation performed by the second memory allocation result with the comparison data by the central processing unit based on the result comparison mode of the kernel function to obtain the test result of the kernel function.
Optionally, in the process of determining the test result of the kernel function, the actual output data of the memory allocation performed according to the second memory allocation result may be compared with the comparison data to obtain the test result of the kernel function.
If there are a plurality of actual output data, each of the actual output data may be compared in sequence, and each of the actual output data may be data for performing memory allocation by using the second memory allocation result.
In the kernel function testing method provided by the embodiment of the application, a second memory allocation result of actual output data obtained in the graphics processor can be determined through the memory allocation unit; synchronizing actual output data of the memory allocation performed by the second memory allocation result to the central processing unit through the memory allocation unit; and comparing the actual output data of the memory allocation performed by the second memory allocation result with the comparison data by the central processing unit based on the result comparison mode of the kernel function to obtain the test result of the kernel function. The memory allocation unit can realize the memory allocation of the actual output data and the transmission of the actual output data, and the memory allocation ratio of the actual output data can be kept unchanged in the process of transmitting the image processor to the central processing unit, so that the determination of the memory allocation ratio of the actual output data in the central processing unit can be realized more accurately and quickly, and the comparison of the control data and the determination of the test result of the kernel function can be realized more quickly.
The following describes apparatuses, devices, and storage media corresponding to the kernel function testing method provided by the present application for execution, and specific implementation processes and technical effects thereof are referred to above, and will not be described again below.
Fig. 9 is a schematic structural diagram of a kernel function testing apparatus according to an embodiment of the present application, and referring to fig. 9, the kernel function testing apparatus includes: an acquisition module 710, an execution module 720, and a comparison module 730.
The obtaining module 710 is configured to obtain, by the central processing unit, test requirement data corresponding to the kernel function to be tested according to the configuration file of the kernel function to be tested, where the test requirement data includes: the method comprises the following steps of inputting data of a kernel function, comparison data of the kernel function, a result comparison mode of the kernel function, resource parameters during kernel function execution, and a thread execution mode, wherein the thread execution mode is used for indicating the number of threads of a plurality of threads related to the kernel function and the execution times of each thread;
the execution module 720 is configured to trigger the kernel function to execute according to the input data and the resource parameters of the kernel function during execution in a thread execution manner through the graphics processor, so as to obtain actual output data of the kernel function;
the comparison module 730 is configured to compare the actual output data with the comparison data by the central processing unit based on a result comparison manner of the kernel function, so as to obtain a test result of the kernel function.
Optionally, the obtaining module 710 is specifically configured to read, from the configuration file, a location of an input data file of the kernel function, a location of a comparison data file of the kernel function, a result comparison manner of the kernel function, a resource parameter when the kernel function is executed, a number of threads, and an execution number of each thread; determining a thread execution mode according to the number of threads and the execution times of each thread; and reading the input data according to the position of the input data file and reading the comparison data according to the position of the comparison data file by the central processing unit.
Optionally, the test requirement data further includes: allocating data to the memory; an execution module 720, specifically configured to obtain memory allocation data from the central processing unit through the memory allocation unit, and determine a first memory allocation result of data input in the central processing unit according to the memory allocation data; synchronizing input data subjected to memory allocation according to the first memory allocation result to the graphics processor through a memory allocation unit; and triggering the kernel function to execute according to the input data of the memory allocation performed by the first memory allocation result and the resource parameters during the execution of the kernel function by the graphics processor in a thread execution mode to obtain the actual output data of the kernel function.
Optionally, the comparing module 730 is specifically configured to determine, by the memory allocation unit, a second memory allocation result of the actual output data obtained in the graphics processor; synchronizing actual output data of the memory allocation performed by the second memory allocation result to the central processing unit through the memory allocation unit; and comparing the actual output data of the memory allocation performed by the second memory allocation result with the comparison data by the central processing unit based on the result comparison mode of the kernel function to obtain the test result of the kernel function.
Optionally, the comparing module 730 is specifically configured to compare the subdata at each position in the actual output data with the subdata at each corresponding position in the comparison data in sequence through the central processing unit; if the subdata at one position in the actual output data is different from the subdata at the corresponding position in the comparison data, determining that the test result is an error; and if the subdata at all the positions in the actual output data is the same as the subdata at all the corresponding positions in the comparison data, determining that no error exists in the test result.
Optionally, the comparing module 730 is specifically configured to compare, by the central processing unit, the first set composed of all the sub-data in the actually output data with the second set composed of all the sub-data in the comparison data; if the types of the subdata in the first set and the subdata in the second set are different, determining that the test result is error; and if the types of the subdata in the first set and the subdata in the second set are the same, determining that no error exists in the test result.
Optionally, the comparing module 730 is further configured to determine the number of actual output data and perform data registration processing according to the number of actual output data.
In the kernel function testing device provided by the embodiment of the application, test requirement data corresponding to the kernel function to be tested can be obtained through the central processing unit according to the configuration file of the kernel function to be tested; triggering the kernel function to execute according to the input data and the resource parameters when the kernel function executes in a thread execution mode through the graphics processor, and obtaining the actual output data of the kernel function; and comparing the actual output data with the comparison data through the central processing unit based on the result comparison mode of the kernel function to obtain the test result of the kernel function. Various data required to be used in the test process can be obtained through the configuration file of the kernel function, so that the test on various kernel functions can be met, and the test universality is improved; in addition, in the testing process, the testing can be carried out according to a thread execution mode, and multithreading and multi-time pressure testing can be considered in the testing process, so that the testing process can be normally executed, the hidden problem of the kernel function in the testing process is found, and the robustness of the kernel function is improved.
The above-mentioned apparatus is used for executing the method provided by the foregoing embodiment, and the implementation principle and technical effect are similar, which are not described herein again.
These above modules may be one or more integrated circuits configured to implement the above methods, such as: one or more Application Specific Integrated Circuits (ASICs), or one or more microprocessors, or one or more Field Programmable Gate Arrays (FPGAs), etc. For another example, when one of the above modules is implemented in the form of a Processing element scheduler code, the Processing element may be a general-purpose processor, such as a Central Processing Unit (CPU) or other processor (e.g., GPU) that can call the program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
Fig. 10 is a schematic mechanism diagram of a computer device according to an embodiment of the present application, and referring to fig. 10, the computer device includes: the memory 810, the central processing unit 820 and the graphics processing unit 830 are connected through a bus 840, a computer program which can run on the central processing unit 820 and the graphics processing unit 830 is stored in the memory 810, and the central processing unit 820 and the graphics processing unit 830 are used for realizing the test method of the kernel function. The software architecture shown in fig. 1 may be run on the computer device, or each module in the kernel function testing apparatus may also be deployed. The cpu 820 and the graphic processor 830 of the computer device may also execute the program stored in the memory 810 to implement the above-described kernel function testing method.
In another aspect of the embodiments of the present application, a computer-readable storage medium is further provided, where the storage medium stores a computer program, and when the computer program is executed by a processor, the computer program implements the steps of the kernel function testing method.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, a division of a unit is merely a logical division, and an actual implementation may have another division, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed.
The integrated unit implemented in the form of a software functional unit may be stored in a computer-readable storage medium. The software functional unit is stored in a storage medium and includes several instructions to enable a computer device (which may be a personal computer, a server, or a network device) or a processor (processor) to execute some steps of the methods according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a portable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other media capable of storing program codes.
The above description is only a preferred embodiment of the present application and is not intended to limit the present application, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims (10)

1. A kernel function testing method is characterized by comprising the following steps:
obtaining test requirement data corresponding to the kernel function to be tested through a central processing unit according to the configuration file of the kernel function to be tested, wherein the test requirement data comprises: the method comprises the following steps of inputting data of a kernel function, comparison data of the kernel function, a result comparison mode of the kernel function, resource parameters during execution of the kernel function and a thread execution mode, wherein the thread execution mode is used for indicating the number of threads of a plurality of threads related to the kernel function and the execution times of each thread;
triggering the kernel function to execute according to the input data and the resource parameters of the kernel function in the execution mode of the thread through a graphic processor, and obtaining the actual output data of the kernel function;
and comparing the actual output data with the comparison data through a central processing unit based on the result comparison mode of the kernel function to obtain the test result of the kernel function.
2. The method for testing kernel functions according to claim 1, wherein the obtaining test requirement data corresponding to the kernel function to be tested according to the configuration file of the kernel function to be tested by the central processing unit comprises:
reading the position of an input data file of the kernel function, the position of a comparison data file of the kernel function, a result comparison mode of the kernel function, resource parameters when the kernel function is executed, the number of threads and the execution times of each thread from the configuration file;
determining the thread execution mode according to the number of the threads and the execution times of each thread;
and reading the input data according to the position of the input data file through a central processing unit, and reading the comparison data according to the position of the comparison data file.
3. The kernel function testing method of claim 1, wherein the test requirement data further comprises: allocating data in a memory; after the test requirement data corresponding to the kernel function to be tested is obtained, the method further includes:
acquiring the memory allocation data from the central processing unit, and determining a first memory allocation result of input data in the central processing unit according to the memory allocation data;
synchronizing input data for memory allocation according to the first memory allocation result to the graphics processor;
the triggering, by the graphics processor, the kernel function to execute according to the input data and the resource parameters of the kernel function when executing in the thread execution mode to obtain actual output data of the kernel function includes:
and triggering the kernel function to execute according to the input data for performing memory allocation by using the first memory allocation result and the resource parameters during the execution of the kernel function by using the graphics processor in the thread execution mode to obtain the actual output data of the kernel function.
4. The method for testing kernel functions according to claim 1, wherein before comparing the actual output data with the control data by the cpu based on the result comparison of the kernel functions to obtain the test result of the kernel functions, the method further comprises:
determining a second memory allocation result of actual output data obtained in the graphics processor;
synchronizing actual output data of memory allocation performed by the second memory allocation result to the central processing unit;
the comparing the actual output data with the comparison data through a central processing unit based on the result comparing mode of the kernel function to obtain the test result of the kernel function comprises the following steps:
and comparing the actual output data of the memory allocation performed by the second memory allocation result with the comparison data through a central processing unit based on the result comparison mode of the kernel function to obtain the test result of the kernel function.
5. The method for testing kernel functions according to claim 1, wherein the comparing the actual output data with the comparison data by the central processing unit based on the result comparing manner of the kernel functions to obtain the test result of the kernel functions comprises:
comparing the subdata at each position in the actual output data with the subdata at each corresponding position in the comparison data in sequence through a central processing unit;
if the subdata at one position in the actual output data is different from the subdata at the corresponding position in the comparison data, determining that an error exists in a test result;
and if the subdata at all positions in the actual output data is the same as the subdata at all corresponding positions in the comparison data, determining that no error exists in the test result.
6. The method for testing kernel functions according to claim 1, wherein the comparing the actual output data with the comparison data by the central processing unit based on the result comparing manner of the kernel functions to obtain the test result of the kernel functions comprises:
comparing, by a central processing unit, a first set of all sub-data in the actual output data with a second set of all sub-data in the comparison data;
if the subdata in the first set is different from the subdata in the second set, determining that an error exists in a test result;
and if the subdata in the first set is the same as the subdata in the second set, determining that no error exists in the test result.
7. The method for testing kernel functions according to claim 1, wherein before comparing the actual output data with the control data by the cpu based on the result comparison of the kernel functions to obtain the test result of the kernel functions, the method further comprises:
and determining the number of the actual output data and performing data registration processing according to the number of the actual output data.
8. A kernel function test apparatus, comprising: the device comprises an acquisition module, an execution module and a comparison module;
the obtaining module is configured to obtain, by the central processing unit, test requirement data corresponding to the kernel function to be tested according to the configuration file of the kernel function to be tested, where the test requirement data includes: the method comprises the following steps of inputting data of a kernel function, comparison data of the kernel function, a result comparison mode of the kernel function, resource parameters during execution of the kernel function and a thread execution mode, wherein the thread execution mode is used for indicating the number of threads of a plurality of threads related to the kernel function and the execution times of each thread;
the execution module is used for triggering the kernel function to execute according to the input data and the resource parameters during the execution of the kernel function in the thread execution mode through a graphic processor, so as to obtain the actual output data of the kernel function;
and the comparison module is used for comparing the actual output data with the comparison data through a central processing unit based on the result comparison mode of the kernel function to obtain the test result of the kernel function.
9. A computer device, comprising: memory, central processing unit and graphics processing unit, the memory, the central processing unit and the graphics processing unit being connected by a bus, the memory having stored therein a computer program executable on the central processing unit and the graphics processing unit, the central processing unit and the graphics processing unit being configured to implement the steps of the method of any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that the storage medium has stored thereon a computer program which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 7.
CN202210958367.9A 2022-08-11 2022-08-11 Kernel function testing method, device, equipment and storage medium Active CN115033497B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210958367.9A CN115033497B (en) 2022-08-11 2022-08-11 Kernel function testing method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210958367.9A CN115033497B (en) 2022-08-11 2022-08-11 Kernel function testing method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN115033497A true CN115033497A (en) 2022-09-09
CN115033497B CN115033497B (en) 2022-11-25

Family

ID=83130962

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210958367.9A Active CN115033497B (en) 2022-08-11 2022-08-11 Kernel function testing method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115033497B (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105528292A (en) * 2015-12-07 2016-04-27 浪潮(北京)电子信息产业有限公司 Kernel unit test method and system based on kernel module
CN106375140A (en) * 2016-08-22 2017-02-01 腾讯科技(深圳)有限公司 Pressure testing method and device
US10108532B1 (en) * 2016-09-29 2018-10-23 Juniper Networks, Inc. Systems and methods for unit testing of operating system kernels from user space
CN109669866A (en) * 2018-12-10 2019-04-23 北京航空航天大学 A kind of acquisition methods of software run time fault propagation path
CN113312254A (en) * 2021-03-29 2021-08-27 阿里巴巴新加坡控股有限公司 Kernel code testing method and device, storage medium and processor
CN113806217A (en) * 2021-08-13 2021-12-17 阿里云计算有限公司 Kernel testing method and device
CN114493980A (en) * 2021-12-30 2022-05-13 清华大学 Kernel function transmission method, device and equipment
CN114691496A (en) * 2022-03-02 2022-07-01 阿里巴巴(中国)有限公司 Unit testing method, unit testing device, computing equipment and medium

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105528292A (en) * 2015-12-07 2016-04-27 浪潮(北京)电子信息产业有限公司 Kernel unit test method and system based on kernel module
CN106375140A (en) * 2016-08-22 2017-02-01 腾讯科技(深圳)有限公司 Pressure testing method and device
US10108532B1 (en) * 2016-09-29 2018-10-23 Juniper Networks, Inc. Systems and methods for unit testing of operating system kernels from user space
CN109669866A (en) * 2018-12-10 2019-04-23 北京航空航天大学 A kind of acquisition methods of software run time fault propagation path
CN113312254A (en) * 2021-03-29 2021-08-27 阿里巴巴新加坡控股有限公司 Kernel code testing method and device, storage medium and processor
CN113806217A (en) * 2021-08-13 2021-12-17 阿里云计算有限公司 Kernel testing method and device
CN114493980A (en) * 2021-12-30 2022-05-13 清华大学 Kernel function transmission method, device and equipment
CN114691496A (en) * 2022-03-02 2022-07-01 阿里巴巴(中国)有限公司 Unit testing method, unit testing device, computing equipment and medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
王立荣等: "Linux内核函数鲁棒性关联测试", 《微型机与应用》 *

Also Published As

Publication number Publication date
CN115033497B (en) 2022-11-25

Similar Documents

Publication Publication Date Title
US8745641B1 (en) Automatic verification and anomaly detection in a representational state transfer (REST) application programming interface
US9519571B2 (en) Method for analyzing transaction traces to enable process testing
US7926114B2 (en) Testing software applications with schema-based fuzzing
US8595701B2 (en) Symbolic execution and test generation for GPU programs
CN108628748B (en) Automatic test management method and automatic test management system
JP2008140162A (en) Debug information collection method
CN112732567B (en) Mock data testing method and device based on ip, electronic equipment and storage medium
CN111427771A (en) Code coverage rate analysis method, equipment, server and readable storage medium
CN110046086B (en) Expected data generation method and device for test and electronic equipment
KR101745392B1 (en) Program analyzing device and computer readble recording medium recording analyzing program
CN115033497B (en) Kernel function testing method, device, equipment and storage medium
EP2972880B1 (en) Kernel functionality checker
US7990980B2 (en) Modeling non-deterministic priority queues for efficient model checking
CN116257226A (en) Data verification method and device, electronic equipment and storage medium
US7024347B2 (en) Transaction conflict testing method and apparatus
US20090235223A1 (en) Program generation apparatus and program generation method
CN114153750B (en) Code checking method and device, code compiling method and electronic equipment
US11061745B2 (en) Shared resource analysis for embedded multi-core systems
CN112241360B (en) Test case generation method, device, equipment and storage medium
CN115964260A (en) Software quality inspection method and related product
CN114185797A (en) Front-end code checking method and device, electronic equipment and readable storage medium
CN116909599A (en) Method, device, equipment and storage medium for upgrading engine offline software
CN114936148A (en) Page testing method and device, electronic equipment and readable storage medium
CN115357474A (en) Local test method, device, equipment and storage medium
CN116383068A (en) Quick test method, device and storage medium of C++ program interface

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant