Memory test method and system, electronic equipment and storage medium
By using vector registers and assembly instructions in the central processor to optimize the memory test algorithm, the problem of long test time and low efficiency in traditional memory testing methods is solved, and fast and efficient memory testing is achieved.
Patent Information
- Application Number
- CN202410899116.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-05
- Publication Date
- 2024-11-08
AI Technical Summary
Traditional memory testing methods have a long test time in large-capacity memory and are inefficient in running, which cannot meet the needs of modern computer equipment for rapid testing.
The vector registers in the central processor are used for memory testing, and the NEON vector registers are used to read and write 128 bits of data, and the XOR comparison is used to determine whether the memory is normal, and the test algorithm is optimized in combination with assembly instructions to improve the testing efficiency.
It significantly shortens memory test time and improves testing efficiency. It is suitable for ARMv8 and above processor architectures, improving processing speed and operation efficiency.
Smart Images

Figure CN118916220A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer storage technology, and in particular to a memory testing method, system, electronic equipment and storage medium. Background Art
[0002] Memory is a crucial component in computers, serving as the communication bridge between the processor and the memory. All computer programs are executed in memory. Given its importance, ensuring memory reliability is crucial during computer operation. Therefore, memory testing is essential. The primary goal of memory testing is to verify that every memory location can store data as much as possible.
[0003] Traditional memory testing methods detect damage by writing, reading, and comparing memory cells. When implemented purely in software, each CPU instruction performs a read, write, and compare operation on only one memory cell, repeating this cycle. With the continuous advancement of technology and the increasing size of memory capacities, this method is time-consuming and inefficient for complex memory tests. Therefore, a memory testing method is urgently needed to address the long testing times and low efficiency of existing memory testing techniques. Summary of the Invention
[0004] In view of the above-mentioned deficiencies in the prior art, the present invention provides a memory testing method, system, electronic device and storage medium, which effectively solve the problems of long memory testing time and low operating efficiency in the prior art.
[0005] In a first aspect of the present invention, the present invention provides a memory testing method applied to a central processing unit, wherein the central processing unit includes a first vector register, a second vector register, and a general register, and the method includes:
[0006] Run a memory test operation instruction through the first vector register to perform read and write access to the memory;
[0007] Writing the data in the general register into the second vector register, and writing all the data in the second vector register into the memory;
[0008] The data in the memory is read into the first vector register, and the first vector register is XOR-compared with the second vector register to determine whether the memory is normal.
[0009] Furthermore, the central processing unit includes a processor architecture of ARMv8 and above.
[0010] Furthermore, executing the memory test operation instruction through the first vector register to perform read and write access to the memory includes:
[0011] Set the memory space address and memory size for memory test;
[0012] Constructing a first vector register value, writing the first vector register value into the memory space address, and incrementing the address pointer pointing to the memory space address until the memory space is full;
[0013] The memory size corresponding to the memory space address is read and compared with the corresponding first vector register value to determine whether the memory is normal.
[0014] Furthermore, comparing the memory size corresponding to the read memory space address with the corresponding first vector register value to determine whether the memory is normal includes:
[0015] If the memory sizes corresponding to all the memory space addresses are the same as the corresponding first vector register values, then it is determined that the memory is normal;
[0016] If the memory size corresponding to the memory space address is different from the corresponding first vector register value, it is determined that the memory is faulty.
[0017] Furthermore, writing the data in the general register into the second vector register, and writing all the data in the second vector register into the memory, includes:
[0018] Saving the byte data in the first vector register to the memory through a first assembly conversion instruction;
[0019] Read the byte data in the memory and store it in the second vector register through a second assembly conversion instruction;
[0020] The data in the general register is bit-flipped and written into the second vector register, and the second vector register writes all the data into the memory.
[0021] Furthermore, the data in the memory is read into the first vector register, and the first vector register is XOR-compared with the second vector register to determine whether the memory is normal:
[0022] Reading all data in the memory into the first vector register, and performing an XOR comparison between the first vector register and the second vector register;
[0023] If the value of the XOR comparison is 0, it is determined that the memory is normal; if the value of the XOR comparison is 1, it is determined that the memory is faulty.
[0024] In a second aspect of the present invention, the present invention provides a memory test system applied to a central processing unit, wherein the central processing unit includes a first vector register, a second vector register, and a general register, and the system includes:
[0025] A first processing module, configured to execute a memory test operation instruction through the first vector register to perform read and write access to the memory;
[0026] a second processing module, configured to write the data in the general register into the second vector register, and write all the data in the second vector register into the memory;
[0027] A memory test module is used to read the data in the memory into the first vector register, perform an XOR comparison between the first vector register and the second vector register, and determine whether the memory is normal.
[0028] Furthermore, the first processing module includes:
[0029] A memory setting unit is used to set the memory space address and memory size of the memory test;
[0030] a value construction unit, configured to construct a first vector register value, write the first vector register value into the memory space address, and increment the address pointer pointing to the memory space address until the memory space is full;
[0031] The comparison and judgment unit is used to read the memory size corresponding to the memory space address and compare it with the corresponding first vector register value to determine whether the memory is normal.
[0032] In the third aspect of the present invention, the present invention provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the memory testing method as described in the first aspect of the present invention is implemented.
[0033] In a fourth aspect of the present invention, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the memory testing method as described in the first aspect of the present invention.
[0034] The present invention provides a memory testing method, system, electronic device, and storage medium. The method is applied to a central processing unit (CPU) of a processor architecture of ARMv8 or above. When running a memory testing algorithm, the vector registers of a hardware device can be used for acceleration. Since the vector registers are 128 bits, for a 64-bit system, a NEON vector register can write two 64-bit data at a time, or read two 64-bit data for comparison. Load and store instructions can then be used to operate multiple memory addresses at once. By combining multiple vector registers and then performing underlying assembly according to the principles of the memory testing algorithm, the test efficiency of the memory testing algorithm can be effectively improved and the test time can be shortened. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without paying any creative work.
[0036] Figure 1 This is a flow chart of a memory testing method provided by an embodiment of the present invention;
[0037] Figure 2 This is a schematic diagram of the structure of a memory test system provided by an embodiment of the present invention;
[0038] Figure 3 2 is a schematic structural diagram of a first processing module in a memory test system according to an embodiment of the present invention;
[0039] Figure 4 It is a structural diagram of an electronic device in an embodiment of the present invention.
[0040] Description of main component symbols:
[0041] 200, memory test system; 210, first processing module; 220, second processing module; 230, memory test module; 211, memory setting unit; 212, numerical value construction unit; 213, comparison and judgment unit; 400, electronic device; 410, processor; 420, communication interface; 430, memory; 440, communication bus. DETAILED DESCRIPTION
[0042] To make the purpose, technical solutions and advantages of the present invention clearer, the technical solutions of the present invention will be further clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. It should be noted that the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0043] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of the technical features being referred to. Thus, a feature identified as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the present invention, "plurality" means two or more, unless otherwise specifically defined.
[0044] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application belongs. The terms used in this specification are for the purpose of describing specific embodiments only and are not intended to limit the present invention. As used herein, the term "and / or" includes any and all combinations of one or more of the associated listed items.
[0045] Traditional memory testing methods rely on writing, reading, and then comparing memory cells to detect damage. When implemented purely in software, each CPU instruction performs a read, write, and compare operation on only one memory cell, repeating this cycle. With the continuous advancement of technology and the increasing size of memory, this method can be time-consuming and inefficient for complex memory testing.
[0046] Example 1
[0047] To address the above-mentioned shortcomings of the prior art, an embodiment of the present invention provides a memory testing method that effectively solves the problems of long memory testing time and low operating efficiency in the prior art. The method is applied to a central processing unit (CPU) comprising an ARMv8 or higher processor architecture, wherein the CPU includes a first vector register, a second vector register, and a general register, wherein both the first vector register and the second vector register are NEON vector registers. Figure 1 This is a flow chart of a memory testing method provided by an embodiment of the present invention. Figure 1 As shown, the method includes the following steps:
[0048] S100, executing a memory test operation instruction through a first vector register to perform read and write access to the memory;
[0049] In an embodiment of the present invention, the memory is read and written by means of the first NEON vector register. Specifically, the memory space address and space size to be tested are first set; then a 128-bit pattern number is written to the first NEON vector register; then the first NEON vector register is used to write the 128-bit pattern number to all addresses of the test memory; finally, the first NEON vector register is used to read the values of all addresses of the test memory and compare them with the pattern number to determine whether the memory is normal.
[0050] If the values of all test memory addresses read out by the first NEON vector register are the same as the pattern number, the memory is judged to be normal; if the values of all test memory addresses read out by the first NEON vector register are different from the pattern number, the memory is judged to be faulty.
[0051] S200 , writing the data in the general register into the second vector register, and writing all the data in the second vector register into the memory.
[0052] In an embodiment of the present invention, memory operation instructions are converted into assembly instructions by means of assembly, thereby improving the running efficiency of the program. Usually in C language code, the way to write a certain data to a memory address is *addr=0x12345678. However, if a certain memory unit is to be read and written by means of assembly, the CPU under the ARM architecture generally uses the LDR instruction and the STR instruction. The LDR instruction is used to save a single word or byte data in the first NEON vector register to the memory, and the STR instruction is used to read a single word or byte data from the memory and store it in the second NEON vector register. Generally speaking, inline assembly is used inside the C language code, and assembly is used in the C language code environment.
[0053] On the ARMv8 architecture, general-purpose registers are typically 64 bits. To move a 64-bit pattern value from a register into the second NEON vector register, two pattern values must be combined to fill the 128-bit NEON vector register. Bit-flipping a pattern value can be accomplished through bit shift operations. Typically, to write the pattern value into the second NEON vector register, two "MOV" instructions are used to shift the value twice to fill the second NEON vector register. Finally, the second NEON vector register loads the pattern value into physical memory using the "ST1" instruction.
[0054] S300 , reading the data in the memory into the first vector register, performing an XOR comparison between the first vector register and the second vector register to determine whether the memory is normal.
[0055] In this embodiment of the present invention, the "LD1" instruction is used to load data from physical memory into the first 128-bit NEON vector register. A specific example is as follows: LD1 V0.2D,[x10],#16, where LD1 is the instruction to load data from memory into a vector register, V0 is the first NEON vector register, 2D indicates two channels, each 64 bits, x10 is a general register that stores the memory address of the current operation, and #16 is an immediate value. After the operation, the memory address corresponding to x10 is incremented by 16.
[0056] After loading the data from the memory into the first NEON vector register, the first NEON vector register and the second NEON vector register are XORed. If the XORed value of the two NEON vector registers is 0, the memory is considered normal. If a bit of the value in a certain memory address is flipped, that is, it is no longer equal to the original pattern value, and the XORed result at this bit position is 1, it indicates that the memory is faulty.
[0057] The memory testing method provided by the embodiment of the present invention can utilize the vector registers of the hardware device to accelerate the execution of the memory testing algorithm. Since the vector register is 128 bits, for a 64-bit system, a NEON vector register can write two 64-bit data at a time, or read two 64-bit data for comparison. Then, load and store instructions can be used to operate multiple memory addresses at a time, which can significantly improve processing speed and efficiency.
[0058] Example 2
[0059] Based on the same technical concept as the method embodiment of the above-mentioned embodiment 1, an embodiment of the present invention provides a memory testing system, which is applied to a central processing unit of a processor architecture including ARMv8 and above, and the central processing unit includes a first vector register, a second vector register and a general register, wherein the first vector register and the second vector register are both NEON vector registers. Figure 2 FIG. 1 is a schematic diagram of a memory test system structure provided by an embodiment of the present invention. Figure 2 As shown, the memory testing system 200 includes:
[0060] The first processing module 210 is configured to execute a memory test operation instruction through a first vector register to perform read and write access to the memory.
[0061] A second processing module 220 is configured to write the data in the general register into the second vector register, and write all the data in the second vector register into the memory;
[0062] The memory test module 230 is used to read the data in the memory into the first vector register, perform an XOR comparison between the first vector register and the second vector register, and determine whether the memory is normal.
[0063] Figure 3 FIG. 1 is a structural diagram of the first processing module in the memory test system according to an embodiment of the present invention. Figure 3 As shown, the first processing module 210 includes:
[0064] A memory setting unit 211 is used to set the memory space address and memory size of the memory test;
[0065] a value construction unit 212 for constructing a first vector register value, writing the first vector register value into the memory space address, and incrementing the address pointer pointing to the memory space address until the memory space is full;
[0066] The comparison and judgment unit 213 is used to read the memory size corresponding to the memory space address and compare it with the corresponding first vector register value to determine whether the memory is normal.
[0067] The memory testing system provided by the embodiment of the present invention utilizes hardware acceleration technology, especially when optimizing the memory testing algorithm for the NEON instruction set in the ARM architecture, multiple vector registers are combined, and then the underlying assembly is performed according to the principles of the memory testing algorithm, which can effectively improve the testing efficiency of the memory testing algorithm and shorten the testing time.
[0068] It can be understood that the implementation of the memory testing method described in the above embodiment 1 is also applicable to this embodiment and can achieve the same technical effect, so it will not be repeated here.
[0069] Example 3
[0070] Based on the same concept, an embodiment of the present invention further provides an electronic device, Figure 4 is a schematic structural diagram of an electronic device provided by an embodiment of the present invention, such as Figure 4 As shown, the electronic device 400 may include: a processor 410, a communication interface 420, a memory 430, and a communication bus 440, wherein the processor 410, the communication interface 420, and the memory 430 communicate with each other via the communication bus 440. The processor 410 may call the logic instructions in the memory 430 to execute the steps of the memory testing method described in the above embodiments. For example, it includes:
[0071] S100, executing a memory test operation instruction through a first vector register to perform read and write access to the memory;
[0072] S200, writing the data in the general register into the second vector register, and writing all the data in the second vector register into the memory;
[0073] S300 , reading the data in the memory into the first vector register, performing an XOR comparison between the first vector register and the second vector register to determine whether the memory is normal.
[0074] The processor 410 may be a central processing unit (CPU). The processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or a combination of the above chips.
[0075] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0076] The memory 430 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created by the processor, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-transitory memory, such as at least one disk storage device, a flash memory device, or other non-transitory solid-state storage device. In some embodiments, the memory may optionally include a memory remotely located relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0077] Example 3
[0078] Based on the same concept, an embodiment of the present invention further provides a computer-readable storage medium storing a computer program. The computer program includes at least one code segment that can be executed by a main control device to control the main control device to implement the steps of the memory testing method described in the above embodiments. For example, the steps include:
[0079] S100, executing a memory test operation instruction through a first vector register to perform read and write access to the memory;
[0080] S200, writing the data in the general register into the second vector register, and writing all the data in the second vector register into the memory;
[0081] S300 , reading the data in the memory into the first vector register, performing an XOR comparison between the first vector register and the second vector register to determine whether the memory is normal.
[0082] Based on the same technical concept, an embodiment of the present invention further provides a computer program, which, when executed by a main control device, is used to implement the above method embodiment.
[0083] The computer program may be stored in whole or in part on a storage medium packaged with the processor, or may be stored in whole or in part on a memory not packaged with the processor.
[0084] Based on the same technical concept, an embodiment of the present invention further provides a processor for implementing the above method embodiment. The above processor may be a chip.
[0085] In summary, the memory testing method, system, electronic device, and storage medium provided by the present invention are applied to a central processing unit of a processor architecture of ARMv8 and above. When running a memory testing algorithm, the vector registers of the hardware device can be used for acceleration. Since the vector registers are 128 bits, for a 64-bit system, a NEON vector register can write two 64-bit data at a time, or read two 64-bit data for comparison, and then use load and store instructions to operate multiple memory addresses at a time. Combining multiple vector registers and then performing bottom-level assembly according to the principles of the memory testing algorithm can effectively improve the test efficiency of the memory testing algorithm and shorten the test time.
[0086] References herein to "embodiments" mean that a particular feature, structure, or characteristic described in connection with the embodiments may be included in at least one embodiment of the present application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute an independent or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0087] The above-described embodiments merely illustrate several implementations of the present invention, and while their descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art would be able to make numerous variations and improvements without departing from the spirit of the present invention, all of which fall within the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be determined by the appended claims.
[0088] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.
Claims
1. A memory testing method, characterized in that: Applied to a central processing unit, the central processing unit includes a first vector register, a second vector register and a general register, and the method includes: Run the memory test operation instruction through the first vector register to read and write access to the memory; Writing the data in the general register into the second vector register, and writing all the data in the second vector register into the memory; The data in the memory is read into the first vector register, and the first vector register is XOR-compared with the second vector register to determine whether the memory is normal.
2. The memory testing method according to claim 1, characterized in that: The central processing unit includes a processor architecture of ARMv8 and above.
3. The memory testing method according to claim 1, characterized in that: The step of executing the memory test operation instruction through the first vector register to read and write access to the memory includes: Set the memory space address and memory size for memory test; Constructing a first vector register value, writing the first vector register value into the memory space address, and incrementing the address pointer pointing to the memory space address until the memory space is full; The memory size corresponding to the read memory space address is compared with the corresponding first vector register value to determine whether the memory is normal.
4. The memory testing method according to claim 3, characterized in that: The memory size corresponding to the read memory space address is compared with the corresponding first vector register value to determine whether the memory is normal, including: If the memory sizes corresponding to all the memory space addresses are the same as the corresponding first vector register values, then it is determined that the memory is normal; If the memory size corresponding to the memory space address is different from the corresponding first vector register value, the memory fault is determined.
5. The memory testing method according to claim 1, characterized in that: Writing the data in the general register into the second vector register, and writing all the data in the second vector register into the memory, comprises: The byte data in the first vector register is saved into the memory through a first assembly conversion instruction; Read the byte data in the memory through a second assembly conversion instruction and store it in the second vector register; The data in the general register is bit-flipped and written into the second vector register, and the second vector register writes all the data into the memory.
6. The memory testing method according to claim 5, characterized in that: The data in the memory is read into the first vector register, and the first vector register is XOR-compared with the second vector register to determine whether the memory is normal: Reading all data in the memory into the first vector register, and performing an XOR comparison between the first vector register and the second vector register; If the XOR comparison value is 0, the memory is determined to be normal; if the XOR comparison value is 1, the memory is determined to be faulty.
7. A memory testing system, characterized in that: Applied to a central processing unit, the central processing unit includes a first vector register, a second vector register and a general register, and the system includes: A first processing module, used for executing a memory test operation instruction through the first vector register to perform read and write access to the memory; A second processing module, used for writing the data in the general register into the second vector register, and writing all the data in the second vector register into the memory; A memory test module is used to read the data in the memory into the first vector register, perform an XOR comparison between the first vector register and the second vector register, and determine whether the memory is normal.
8. The memory testing system according to claim 7, characterized in that: The first processing module comprises: A memory setting unit, used to set the memory space address and memory size of the memory test; a value construction unit, used for constructing a first vector register value, writing the first vector register value into the memory space address, and incrementing the address pointer pointing to the memory space address until the memory space is full; The comparison and judgment unit is used to read the memory size corresponding to the memory space address and compare it with the corresponding first vector register value to determine whether the memory is normal.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the memory testing method according to any one of claims 1 to 6 is implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the memory testing method according to any one of claims 1 to 6 is implemented.
