[go: up one dir, main page]

CN114691434A - Characteristic detection method and device of processor - Google Patents

Characteristic detection method and device of processor Download PDF

Info

Publication number
CN114691434A
CN114691434A CN202011568419.9A CN202011568419A CN114691434A CN 114691434 A CN114691434 A CN 114691434A CN 202011568419 A CN202011568419 A CN 202011568419A CN 114691434 A CN114691434 A CN 114691434A
Authority
CN
China
Prior art keywords
processor
characteristic
detection
executable file
detection instruction
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.)
Pending
Application number
CN202011568419.9A
Other languages
Chinese (zh)
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.)
Longxin Zhongke Hefei Technology Co ltd
Original Assignee
Longxin Zhongke Hefei 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 Longxin Zhongke Hefei Technology Co ltd filed Critical Longxin Zhongke Hefei Technology Co ltd
Priority to CN202011568419.9A priority Critical patent/CN114691434A/en
Publication of CN114691434A publication Critical patent/CN114691434A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/22Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing
    • G06F11/2205Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing using arrangements specific to the hardware being tested
    • G06F11/2236Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing using arrangements specific to the hardware being tested to test CPU or processors
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/22Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing
    • G06F11/2273Test methods

Landscapes

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

Abstract

本发明实施例提供一种处理器的特性检测方法和装置,该方法包括:在编译应用程序时获取第一特性参数;根据第一特性参数,判断运行应用程序的第一处理器是否需要进行第一检测,第一检测为检测第一处理器是否支持特性检测指令;当不需要进行第一检测且明确第一处理器支持特性检测指令时,生成第一可执行文件,第一可执行文件包括使用特性检测指令获取处理器特性信息的二进制码;当需要进行第一检测时,生成第二可执行文件,以使第一处理器在运行第二可执行文件时确定第一处理器是否支持特性检测指令并根据确定结果获取处理器特性信息。本发明实施例能够在保证处理器不出现崩溃的情况下用最快速的方式实现处理器特性检测,提高了特性检测效率。

Figure 202011568419

Embodiments of the present invention provide a method and device for detecting characteristics of a processor. The method includes: acquiring a first characteristic parameter when compiling an application program; and judging, according to the first characteristic parameter, whether a first processor running the application needs to perform a A detection, the first detection is to detect whether the first processor supports the feature detection instruction; when the first detection is not required and it is clear that the first processor supports the feature detection instruction, a first executable file is generated, and the first executable file includes Use the feature detection instruction to obtain the binary code of the processor feature information; when the first detection needs to be performed, a second executable file is generated, so that the first processor can determine whether the first processor supports the feature when running the second executable file. The instruction is detected and processor characteristic information is obtained according to the determination result. The embodiments of the present invention can implement processor characteristic detection in the fastest way under the condition that the processor does not crash, thereby improving the characteristic detection efficiency.

Figure 202011568419

Description

处理器的特性检测方法和装置Characteristic detection method and device of processor

技术领域technical field

本发明实施例涉及计算机软件技术领域,尤其涉及一种处理器的特性检测方法和装置。Embodiments of the present invention relate to the technical field of computer software, and in particular, to a method and apparatus for detecting characteristics of a processor.

背景技术Background technique

处理器的更新通常也伴随着新的特性或者说新的指令集产生,新版本的处理器可以兼容支持旧处理器能支持的特性,但是旧版本的处理器不可能支持新的特性。对于软件开发者而言,通常会面临同一份可执行程序需要支持多款处理器,即支持多种处理器特性的要求。因此,软件开发者就需要向软件中添加运行时处理器特性检查的相关检测指令,然后根据不同处理器的特性支持情况选择执行不同的实现。比如,旧版本的处理器上只支持64位SIMD指令,而新版本的处理器平台上除了64位SIMD之外新支持了新的128位SIMD指令。The update of the processor is usually accompanied by new features or new instruction sets. The new version of the processor can support the features that the old processor can support, but the old version of the processor cannot support the new features. For software developers, the same executable program usually needs to support multiple processors, that is, the requirement to support multiple processor features. Therefore, the software developer needs to add the relevant detection instructions of the runtime processor characteristic check to the software, and then choose to execute different implementations according to the characteristic support of different processors. For example, the old version of the processor only supports 64-bit SIMD instructions, and the new version of the processor platform supports new 128-bit SIMD instructions in addition to 64-bit SIMD.

相关技术中,为了便于软件开发者在处理器运行时实现对处理器的特性检测,提供了两种处理器特性检测方法。第一种是,开发者可以利用处理器检测指令来检查处理器特性,即,将特性检测指令编译至开发的软件项目的应用程序中,处理器运行该应用程序时执行特性检测指令并返回该处理器能支持的特性信息,软件开发者根据处理器的返回结果来判断该处理器能支持哪些特性。第二种就是解析cpuinfo文件来获取处理器支持的特性。In the related art, in order to facilitate the software developer to realize the characteristic detection of the processor when the processor is running, two processor characteristic detection methods are provided. The first is that the developer can use the processor detection instruction to check the characteristics of the processor, that is, the characteristic detection instruction is compiled into the application program of the developed software project, and the processor executes the characteristic detection instruction when running the application program and returns the Information about the features that the processor can support. The software developer determines which features the processor can support according to the returned result of the processor. The second is to parse the cpuinfo file to obtain the features supported by the processor.

然而,上述两种方法分别存在如下问题:第一种方法中的特性检测指令本身也类似于处理器的特性,不是所有的处理器都能支持,如果软件实现中统一都强制运行该指令来检测所有处理器特性,那么会导致软件在某些不支持该特性检测指令的处理器上发生崩溃;第二种方法虽然适应性强,适用于所有处理器特性检测,但是耗费时间长、检测效率很低。However, the above two methods have the following problems: the feature detection instruction in the first method is also similar to the characteristics of the processor itself, and not all processors can support it. If the software implementation is uniformly forced to run this instruction to detect All processor features, then the software will crash on some processors that do not support the feature detection instruction; although the second method is adaptable and suitable for all processor feature detection, it takes a long time and the detection efficiency is very high. Low.

发明内容SUMMARY OF THE INVENTION

本发明实施例提供一种处理器的特性检测方法和装置,以解决现有技术中处理器特性检测容易使得处理器崩溃以及检测耗费时间长的技术问题。Embodiments of the present invention provide a method and apparatus for detecting characteristics of a processor, so as to solve the technical problems in the prior art that the detection of processor characteristics easily causes the processor to crash and the detection takes a long time.

本发明实施例的第一方面提供一种处理器的特性检测方法,包括:A first aspect of the embodiments of the present invention provides a method for detecting characteristics of a processor, including:

在编译应用程序时,获取第一特性参数;When compiling the application, obtain the first characteristic parameter;

根据所述第一特性参数,判断运行该应用程序的第一处理器是否需要进行第一检测,所述第一检测为检测所述第一处理器是否支持特性检测指令;According to the first characteristic parameter, determine whether the first processor running the application needs to perform a first detection, and the first detection is to detect whether the first processor supports a characteristic detection instruction;

当不需要进行所述第一检测且明确所述第一处理器支持所述特性检测指令时,根据所述应用程序源码及判断结果生成第一可执行文件,所述第一可执行文件包括使用所述特性检测指令获取处理器特性信息的二进制码;When it is not necessary to perform the first detection and it is clear that the first processor supports the characteristic detection instruction, a first executable file is generated according to the application source code and the judgment result, and the first executable file includes using The characteristic detection instruction obtains the binary code of the processor characteristic information;

当需要进行所述第一检测时,根据所述应用程序源码及判断结果生成第二可执行文件,以使所述第一处理器在运行所述第二可执行文件时确定所述第一处理器是否支持所述特性检测指令并根据所述确定结果获取处理器特性信息。When the first detection needs to be performed, a second executable file is generated according to the application source code and the judgment result, so that the first processor determines the first process when running the second executable file whether the processor supports the characteristic detection instruction, and obtains processor characteristic information according to the determination result.

可选的,所述方法还包括:Optionally, the method further includes:

当不需要进行所述第一检测且明确所述第一处理器不支持所述特性检测指令时,根据所述应用程序源码及判断结果生成第三可执行文件,所述第三可执行文件包括读取cpuinfo文件获取处理器特性信息的二进制码。When it is not necessary to perform the first detection and it is clear that the first processor does not support the characteristic detection instruction, a third executable file is generated according to the application source code and the judgment result, and the third executable file includes Read the cpuinfo file to obtain the binary code of processor characteristic information.

可选的,所述根据所述确定结果获取处理器特性信息,包括:Optionally, the acquiring processor characteristic information according to the determination result includes:

若确定所述第一处理器支持所述特性检测指令,则使用所述特性检测指令获取处理器特性信息;If it is determined that the first processor supports the characteristic detection instruction, use the characteristic detection instruction to obtain processor characteristic information;

若确定所述第一处理器不支持所述特性检测指令,则读取cpuinfo文件获取处理器特性信息。If it is determined that the first processor does not support the characteristic detection instruction, read the cpuinfo file to obtain processor characteristic information.

可选的,所述使用所述特性检测指令获取处理器特性信息,包括:Optionally, the obtaining processor characteristic information by using the characteristic detection instruction includes:

控制所述第一处理器运行所述第一可执行文件,以在运行所述第一可执行文件时执行所述特性检测指令;controlling the first processor to run the first executable file, so as to execute the characteristic detection instruction when running the first executable file;

获取执行所述特性检测指令时生成的特性标识;obtaining the feature identifier generated when the feature detection instruction is executed;

解析所述特性标识,得到所述第一处理器支持的特性信息。Parse the feature identifier to obtain feature information supported by the first processor.

可选的,所述读取cpuinfo文件获取处理器特性信息,包括:Optionally, the reading of the cpuinfo file to obtain processor characteristic information includes:

控制所述第一处理器运行所述第三可执行文件,以在运行所述第三可执行文件时读取并解析所述cpuinfo文件,得到所述第一处理器支持的特性信息。Controlling the first processor to run the third executable file, so as to read and parse the cpuinfo file when running the third executable file, to obtain feature information supported by the first processor.

本发明实施例的第二方面提供一种处理器的特性检测装置,包括:A second aspect of the embodiments of the present invention provides a device for detecting characteristics of a processor, including:

获取模块,用于在编译应用程序时,获取第一特性参数;Obtaining a module for obtaining the first characteristic parameter when compiling an application;

判断模块,用于根据所述第一特性参数,判断运行该应用程序的第一处理器是否需要进行第一检测,所述第一检测为检测所述第一处理器是否支持特性检测指令;a judgment module, configured to judge whether the first processor running the application needs to perform a first detection according to the first characteristic parameter, and the first detection is to detect whether the first processor supports a characteristic detection instruction;

检测模块,用于当不需要进行所述第一检测且明确所述第一处理器支持所述特性检测指令时,根据所述应用程序源码及判断结果生成第一可执行文件,所述第一可执行文件包括直接使用所述特性检测指令获取处理器特性信息的二进制码;A detection module, configured to generate a first executable file according to the application source code and the judgment result when the first detection does not need to be performed and it is clear that the first processor supports the characteristic detection instruction, the first executable The executable file includes binary code that directly uses the feature detection instruction to obtain processor feature information;

所述检测模块还用于当需要进行所述第一检测时,根据所述应用程序源码及判断结果生成第二可执行文件,以使所述第一处理器在运行所述第二可执行文件时确定所述第一处理器是否支持所述特性检测指令并根据所述确定结果进行处理器特性信息获取。The detection module is further configured to generate a second executable file according to the application source code and the judgment result when the first detection needs to be performed, so that the first processor is running the second executable file At this time, it is determined whether the first processor supports the characteristic detection instruction, and processor characteristic information is acquired according to the determination result.

可选的,所述检测模块还用于:Optionally, the detection module is also used for:

当不需要进行所述第一检测且明确所述第一处理器不支持所述特性检测指令时,根据所述应用程序源码及判断结果生成第三可执行文件,所述第三可执行文件包括读取cpuinfo文件获取处理器特性信息的二进制码。When it is not necessary to perform the first detection and it is clear that the first processor does not support the characteristic detection instruction, a third executable file is generated according to the application source code and the judgment result, and the third executable file includes Read the cpuinfo file to obtain the binary code of processor characteristic information.

可选的,所述检测模块具体用于:Optionally, the detection module is specifically used for:

若确定所述第一处理器支持所述特性检测指令,则使用所述特性检测指令获取处理器特性信息;If it is determined that the first processor supports the characteristic detection instruction, use the characteristic detection instruction to obtain processor characteristic information;

若确定所述第一处理器不支持所述特性检测指令,则读取cpuinfo文件获取处理器特性信息。If it is determined that the first processor does not support the characteristic detection instruction, read the cpuinfo file to obtain processor characteristic information.

可选的,所述检测模块包括:Optionally, the detection module includes:

第一控制单元,用于控制所述第一处理器运行所述第一可执行文件,以在运行所述第一可执行文件时执行所述特性检测指令;a first control unit, configured to control the first processor to run the first executable file, so as to execute the characteristic detection instruction when running the first executable file;

获取单元,用于获取执行所述特性检测指令时生成的特性标识;an acquisition unit, configured to acquire the characteristic identifier generated when the characteristic detection instruction is executed;

第一解析单元,用于解析所述特性标识,得到所述第一处理器支持的特性信息。A first parsing unit, configured to parse the feature identifier to obtain feature information supported by the first processor.

可选的,所述检测模块包括:第二控制单元,用于控制所述第一处理器运行所述第三可执行文件;Optionally, the detection module includes: a second control unit, configured to control the first processor to run the third executable file;

读取单元,用于在所述第一处理器运行所述第三可执行文件时读取cpuinfo文件;a reading unit, configured to read the cpuinfo file when the first processor runs the third executable file;

第二解析单元,用于解析所述cpuinfo文件,得到所述第一处理器支持的特性信息。A second parsing unit, configured to parse the cpuinfo file to obtain feature information supported by the first processor.

本发明实施例提供一种处理器的特性检测方法和装置,该方法通过在编译应用程序时先获取第一特性参数,通过第一特性参数来判断运行该应用程序的第一处理器是否需要进行第一检测,第一检测即判断第一处理器是否支持特性检测指令,若不需要对第一处理器进行第一检测,则说明第一处理器已明确支持特性检测指令或已明确不支持特性检测指令,对于已经明确支持特性检测指令的第一处理器,则生成第一可执行文件,第一可执行文件包括使用所述特性检测指令获取处理器特性信息的二进制码,第一处理器运行第一可执行文件便可以直接使用检测速度更快的特性检测指令的方式检测其所支持的特性信息,为明确知道处理器支持特性检测指令的场合提供一条最快速的特性检查方法,不用所有的场合都去先检查是否支持特性检查指令。若需要对第一处理器进行第一检测,则说明不确定第一处理器是否支持特性检测指令,因此,生成第二可执行文件,第一处理器在运行第二可执行文件的同时确定第一处理器是否支持所述特性检测指令并根据所述确定结果获取处理器特性信息。对于不明确处理器是否支持特性检测指令的情况,先确定第一处理器是否支持特性检测指令,根据确定结果选择特性检测方法,从而在避免了第一处理器在不支持特性检测指令的情况下盲目对其进行特性检测导致的崩溃情况,能够在保证处理器不出现崩溃的情况下,用最快速的方式实现处理器特性检测,提高了特性检测效率。Embodiments of the present invention provide a method and device for detecting characteristics of a processor. The method first obtains a first characteristic parameter when compiling an application program, and determines whether the first processor running the application program needs to perform the first characteristic parameter according to the first characteristic parameter. The first detection, the first detection is to determine whether the first processor supports the feature detection instruction. If the first detection does not need to be performed on the first processor, it means that the first processor has explicitly supported the feature detection instruction or has clearly not supported the feature. detection instruction, for the first processor that has explicitly supported the characteristic detection instruction, a first executable file is generated, and the first executable file includes the binary code for obtaining processor characteristic information by using the characteristic detection instruction, and the first processor runs The first executable file can directly detect the feature information supported by the feature detection instruction with a faster detection speed, and provides the fastest feature check method for the case where it is clear that the processor supports the feature detection instruction, without all the features. In all cases, first check whether the feature check command is supported. If it is necessary to perform the first detection on the first processor, it means that it is uncertain whether the first processor supports the feature detection instruction. Therefore, a second executable file is generated, and the first processor determines the first executable file while running the second executable file. Whether a processor supports the characteristic detection instruction and obtains processor characteristic information according to the determination result. In the case where it is unclear whether the processor supports the feature detection command, first determine whether the first processor supports the feature detection command, and select the feature detection method according to the determination result, so as to avoid the situation that the first processor does not support the feature detection command The crash situation caused by blindly performing feature detection on it can realize the processor feature detection in the fastest way under the condition of ensuring that the processor does not crash, which improves the feature detection efficiency.

附图说明Description of drawings

为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to explain the embodiments of the present invention or the technical solutions in the prior art more clearly, the following briefly introduces the accompanying drawings that need to be used in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only These are some embodiments of the present invention, and for those of ordinary skill in the art, other drawings can also be obtained from these drawings without any creative effort.

图1是本发明一示例性实施例示出的处理器的特性检测方法的应用场景图;FIG. 1 is an application scenario diagram of a method for detecting characteristics of a processor according to an exemplary embodiment of the present invention;

图2是本发明一示例性实施例示出的处理器的特性检测方法的流程示意图;2 is a schematic flowchart of a method for detecting characteristics of a processor according to an exemplary embodiment of the present invention;

图3是本发明另一示例性实施例示出的处理器的特性检测方法的流程示意图;3 is a schematic flowchart of a method for detecting a characteristic of a processor according to another exemplary embodiment of the present invention;

图4是本发明另一示例性实施例示出的处理器的特性检测方法的流程示意图;4 is a schematic flowchart of a method for detecting a characteristic of a processor according to another exemplary embodiment of the present invention;

图5是本发明另一示例性实施例示出的处理器的特性检测方法的流程示意图;5 is a schematic flowchart of a method for detecting a characteristic of a processor according to another exemplary embodiment of the present invention;

图6是本发明另一示例性实施例示出的处理器的特性检测方法的流程示意图;6 is a schematic flowchart of a method for detecting a characteristic of a processor according to another exemplary embodiment of the present invention;

图7是本发明一示例性实施例示出的处理器的特性检测装置的结构示意图;7 is a schematic structural diagram of an apparatus for detecting characteristics of a processor according to an exemplary embodiment of the present invention;

图8是本发明一示例性实施例示出的处理器的特性检测装置中检测模块的结构示意图;8 is a schematic structural diagram of a detection module in a device for detecting characteristics of a processor according to an exemplary embodiment of the present invention;

图9是本发明一示例性实施例示出的电子设备的结构示意图。FIG. 9 is a schematic structural diagram of an electronic device according to an exemplary embodiment of the present invention.

具体实施方式Detailed ways

为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make the purposes, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments It is only a part of the embodiments of the present invention, but not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

本发明的说明书和权利要求书及上述附图中的术语“第一”、“第二”、“第三”“第四”等(如果存在)是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本发明的实施例例如能够以除了在这里图示或描述的那些以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。The terms "first", "second", "third", "fourth", etc. (if present) in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to Describe a particular order or sequence. It is to be understood that the data so used are interchangeable under appropriate circumstances such that the embodiments of the invention described herein can, for example, be practiced in sequences other than those illustrated or described herein. Furthermore, the terms "comprising" and "having" and any variations thereof, are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those expressly listed Rather, those steps or units may include other steps or units not expressly listed or inherent to these processes, methods, products or devices.

处理器的更新通常也伴随着新的特性或者说新的指令集产生,新版本的处理器可以兼容支持旧处理器能支持的特性,但是旧版本的处理器不可能支持新的特性。对于软件开发者而言,通常会面临同一份可执行程序需要支持多款处理器,即支持多种处理器特性的要求。因此,软件开发者就需要向软件中添加运行时处理器特性检查的相关检测指令,然后根据不同处理器的特性支持情况选择执行不同的实现。比如,旧版本的处理器上只支持64位SIMD指令,而新版本的处理器平台上除了64位SIMD之外新支持了新的128位SIMD指令。The update of the processor is usually accompanied by new features or new instruction sets. The new version of the processor can support the features that the old processor can support, but the old version of the processor cannot support the new features. For software developers, the same executable program usually needs to support multiple processors, that is, the requirement to support multiple processor features. Therefore, the software developer needs to add the relevant detection instructions of the runtime processor characteristic check to the software, and then choose to execute different implementations according to the characteristic support of different processors. For example, the old version of the processor only supports 64-bit SIMD instructions, and the new version of the processor platform supports new 128-bit SIMD instructions in addition to 64-bit SIMD.

相关技术中,为了确保软件对大多数处理器的兼容,需要在软件中实现处理器特性的运行时检查。以linux系统环境为例,检查方法一般有两种。第一种是,开发者可以利用处理器检测指令来检查处理器特性,即,将特性检测指令编译至开发的软件项目的应用程序中,处理器运行应用程序时能够执行该特性检测指令并返回该处理器能支持的特性信息,软件开发者根据处理器的返回结果来判断该处理器能支持哪些特性。然而,这种方法虽然检测速度快,但是特性检测指令本身也类似于处理器的特性,不是所有的处理器都能支持,如果软件实现中统一都强制运行该指令来检测所有处理器特性,那么会导致软件在某些不支持该特性检测指令的处理器上发生崩溃。第二种方法就是解析cpuinfo文件来获取处理器支持的特性。然而,这种方法虽然适应性强,适用于所有处理器特性检测,但是耗费时间长、检测效率很低。In the related art, in order to ensure the compatibility of software with most processors, it is necessary to implement runtime checking of processor characteristics in software. Taking the Linux system environment as an example, there are generally two inspection methods. The first is that the developer can use the processor detection instruction to check the characteristics of the processor, that is, the characteristic detection instruction is compiled into the application program of the developed software project, and the processor can execute the characteristic detection instruction when the application program is run and return Information about the features that the processor can support. The software developer determines which features the processor can support according to the returned result of the processor. However, although this method has a fast detection speed, the feature detection instruction itself is similar to the characteristics of the processor, and not all processors can support it. If the software implementation forces the execution of this instruction to detect all processor characteristics, then Causes the software to crash on some processors that do not support the feature detection instruction. The second method is to parse the cpuinfo file to obtain the features supported by the processor. However, although this method is adaptable and suitable for all processor feature detection, it takes a long time and the detection efficiency is very low.

针对此缺陷,本发明的技术方案主要在于:在编译应用程序时先获取第一特性参数,通过第一特性参数来判断运行该应用程序的第一处理器是否需要进行第一检测,第一检测即判断第一处理器是否支持特性检测指令,若不需要对第一处理器进行第一检测,则说明第一处理器已明确支持特性检测指令或已明确不支持特性检测指令,对于已经明确支持特性检测指令的第一处理器,则生成第一可执行文件,第一可执行文件包括直接使用所述特性检测指令获取处理器特性信息的二进制码,第一处理器运行第一可执行文件便可以直接使用检测速度更快的特性检测指令的方式检测其所支持的特性信息,为明确知道处理器支持特性检测指令的场合提供一条最快速的特性检查方法,不用所有的场合都去先检查是否支持特性检查指令;若已明确第一处理器不支持特性检测指令,则读取cpuinfo文件获取第一处理器的特性信息,避免了盲目使用特新检测指令导致第一处理器崩溃的情况。若需要对第一处理器进行第一检测,则说明不确定第一处理器是否支持特性检测指令,因此,生成第二可执行文件,第一处理器在运行第二可执行文件的同时确定第一处理器是否支持所述特性检测指令并根据所述确定结果获取处理器特性信息。对于不明确处理器是否支持特性检测指令的情况,先确定第一处理器是否支持特性检测指令,根据确定结果选择特性检测方法,从而在避免了第一处理器在不支持特性检测指令的情况下盲目对其进行特性检测导致的崩溃情况,能够在保证处理器不出现崩溃的情况下,用最快速的方式实现处理器特性检测,提高了特性检测效率。Aiming at this defect, the technical solution of the present invention mainly lies in: first obtaining a first characteristic parameter when compiling an application program, and using the first characteristic parameter to determine whether the first processor running the application program needs to perform a first detection, the first detection That is, it is judged whether the first processor supports the feature detection command. If the first detection is not required for the first processor, it means that the first processor has explicitly supported the feature detection command or has clearly not supported the feature detection command. The first processor of the characteristic detection instruction generates a first executable file, and the first executable file includes the binary code that directly uses the characteristic detection instruction to obtain the processor characteristic information, and the first processor runs the first executable file. The feature information supported by the feature detection instruction can be directly detected by the method of detecting the feature detection command with a faster detection speed, and the fastest feature check method is provided for the occasions where the processor supports the feature detection command. Supports the feature check command; if it is clear that the first processor does not support the feature check command, read the cpuinfo file to obtain the feature information of the first processor, so as to avoid the crash of the first processor caused by blindly using the new check command. If it is necessary to perform the first detection on the first processor, it means that it is uncertain whether the first processor supports the feature detection instruction. Therefore, a second executable file is generated, and the first processor determines the first executable file while running the second executable file. Whether a processor supports the characteristic detection instruction and obtains processor characteristic information according to the determination result. In the case where it is unclear whether the processor supports the feature detection command, first determine whether the first processor supports the feature detection command, and select the feature detection method according to the determination result, so as to avoid the situation that the first processor does not support the feature detection command The crash situation caused by blindly performing feature detection on it can realize the processor feature detection in the fastest way under the condition of ensuring that the processor does not crash, which improves the feature detection efficiency.

图1是本发明一示例性实施例示出的处理器的特性检测方法的应用场景图。FIG. 1 is an application scenario diagram of a method for detecting characteristics of a processor according to an exemplary embodiment of the present invention.

如图1所示,该场景包括第一客户端101和第二客户端102,其中,第一客户端101中的处理器为旧版本的处理器,第二客户端102中的处理器为新版本的处理器,为了对比检测第二客户端中的新版本的处理器和第一客户端中的旧版本的处理器都支持哪些特性,可以直接获取相应处理器中的cpuinfo文件来获取处理器支持的特性;也可以在开发的软件项目(比如应用程序APP)中增加特性检测指令,然后相关技术人员点击应用程序APP,相应的客户端中的处理器在运行该应用程序的同时执行特性检测指令,然后处理器将运行结果远程发送至显示终端103显示,运行结果包括第一客户端的处理器的特性信息和第二客户端的处理器的特性信息。As shown in FIG. 1 , the scenario includes a first client 101 and a second client 102, wherein the processor in the first client 101 is an old version processor, and the processor in the second client 102 is a new version Version of the processor, in order to compare and detect which features are supported by the new version of the processor in the second client and the old version of the processor in the first client, you can directly obtain the cpuinfo file in the corresponding processor to obtain the processor Supported features; it is also possible to add feature detection instructions in the developed software project (such as application APP), and then the relevant technical personnel click on the application APP, and the processor in the corresponding client will execute the feature detection while running the application. instruction, and then the processor remotely sends the operation result to the display terminal 103 for display, where the operation result includes characteristic information of the processor of the first client and characteristic information of the processor of the second client.

图2是本发明一示例性实施例示出的处理器的特性检测方法的流程示意图,本实施例提供的方法的执行主体可以是图1所示实施例中的客户端,也可以是服务器端,本实施例中不做具体限定。FIG. 2 is a schematic flowchart of a method for detecting characteristics of a processor according to an exemplary embodiment of the present invention. The execution body of the method provided by this embodiment may be the client in the embodiment shown in FIG. 1 or the server. There is no specific limitation in this embodiment.

如图2所示,本实施例提供的方法主要包括以下步骤。As shown in FIG. 2 , the method provided by this embodiment mainly includes the following steps.

S201,在编译应用程序时,获取第一特性参数。S201, when compiling an application program, obtain a first characteristic parameter.

其中,第一特性参数用来标识相应的处理器是否明确支持特性检测指令。The first characteristic parameter is used to identify whether the corresponding processor explicitly supports the characteristic detection instruction.

S202,根据所述第一特性参数,判断运行该应用程序的第一处理器是否需要进行第一检测,所述第一检测为检测所述第一处理器是否支持特性检测指令。S202, according to the first characteristic parameter, determine whether the first processor running the application needs to perform a first detection, where the first detection is to detect whether the first processor supports a characteristic detection instruction.

具体的,技术人员在配置处理器时,很多都知道自己配置的处理器是否支持特性检测指令,因此,技术人员可以预先通过操作终端在处理器中设置一些特性参数,通过特性参数来标识处理器是否明确支持特性检测指令。Specifically, when configuring a processor, many technicians know whether the processor they configure supports the feature detection command. Therefore, the technician can set some feature parameters in the processor through the operation terminal in advance, and identify the processor by the feature parameter. Whether to explicitly support feature detection directives.

在一种可能的实施例中,技术人员可以在明确支持特性检测指令的处理器中设置特性检测参数,对于不明确是否支持特性检测指令的处理器中不设置特性检测参数。在第一处理器运行编译的应用程序时,先获取第一处理器的第一特性参数,若存在第一特性参数,则说明第一处理器明确支持特性检测指令,因此不需要对第一处理器进行第一检测;若不存在第一特性参数,则说明不确定第一处理器是否支持特性检测指令,为了选择快速且安全的特性检测方式,则需要对第一处理器进行第一检测,以检测第一处理器是否支持特性检测指令。In a possible embodiment, a technician may set a feature detection parameter in a processor that explicitly supports the feature detection instruction, and does not set a feature detection parameter in a processor that does not explicitly support the feature detection instruction. When the first processor runs the compiled application program, it first obtains the first characteristic parameter of the first processor. If the first characteristic parameter exists, it means that the first processor explicitly supports the characteristic detection instruction, so it is not necessary to process the first characteristic parameter. If there is no first characteristic parameter, it means that it is uncertain whether the first processor supports the characteristic detection instruction. In order to select a fast and safe characteristic detection method, the first detection needs to be performed on the first processor. to detect whether the first processor supports the feature detection instruction.

示例性的,假设待检测的处理器有三个,分别为处理器A、处理器B和处理器C,其中,处理器A和处理器B是检测技术人员配置的,检测技术人员知道处理器A和B支持特性检测指令,而处理器C不是该检测技术人员配置的,其不知道处理器C是否能够支持特性检测指令。因此检测技术人员可以预先通过操作终端在处理器A和处理器B中设置特性参数,在处理器C中不设置特性参数。当处理器A、B和C分别运行编译的应用程序时能够获取到处理器A和B的特性参数,但是获取不到处理器C的特性参数,则说明处理器A和B都支持特性检测指令,处理器C不能确定是否支持特性检测指令,因此不可以直接使用特性检测指令来检测处理器C的特性,需要对处理器C进行第一检测,以检测处理器C是否支持特性检测指令。Exemplarily, it is assumed that there are three processors to be detected, namely processor A, processor B, and processor C, wherein processor A and processor B are configured by a testing technician, and the testing technician knows processor A. And B supports the feature detection instruction, but the processor C is not configured by the testing technician, who does not know whether the processor C can support the feature detection instruction. Therefore, inspection technicians can set characteristic parameters in processor A and processor B in advance through the operation terminal, but do not set characteristic parameters in processor C. When processors A, B, and C run the compiled application programs respectively, the characteristic parameters of processors A and B can be obtained, but the characteristic parameters of processor C cannot be obtained, which means that both processors A and B support the characteristic detection instruction , the processor C cannot determine whether to support the feature detection instruction, so the feature detection instruction cannot be directly used to detect the characteristics of the processor C, and the first detection of the processor C needs to be performed to detect whether the processor C supports the feature detection instruction.

在另一种可能的实施例中,技术人员可以分别在明确支持特性检测指令的处理器和不明确是否支持特性检测指令的处理器中设置数值不同的特性参数,处理器在运行编译的应用程序时根据获取到的特性参数的数值,来确定处理器是否进行第一检测。可选的,用特性参数00标识处理器明确支持特性检测指令,用特性参数10标识处理器不能直接使用特性检测指令,需要进行第一检测以进一步判断其是否支持特性检测指令。当第一处理器运行编译的应用程序时,若获取到的第一处理器的特性参数为00,则说明第一处理器明确支持特性检测指令,不需要对第一处理器进行第一检测;若获取到的第一处理器的特性参数为10,则说明不明确第一处理器是否支持特性检测指令,需要对第一处理器进行第一检测。In another possible embodiment, the technician may set different characteristic parameters in the processor that explicitly supports the characteristic detection instruction and the processor that does not clearly support the characteristic detection instruction, and the processor is running the compiled application program. At the time, it is determined whether the processor performs the first detection according to the acquired value of the characteristic parameter. Optionally, the characteristic parameter 00 is used to indicate that the processor explicitly supports the characteristic detection instruction, and the characteristic parameter 10 is used to indicate that the processor cannot directly use the characteristic detection instruction, and a first detection is required to further determine whether it supports the characteristic detection instruction. When the first processor runs the compiled application program, if the acquired characteristic parameter of the first processor is 00, it means that the first processor explicitly supports the characteristic detection instruction and does not need to perform the first detection on the first processor; If the acquired characteristic parameter of the first processor is 10, it means that it is unclear whether the first processor supports the characteristic detection instruction, and the first detection needs to be performed on the first processor.

S203,当不需要进行所述第一检测且明确所述第一处理器支持所述特性检测指令时,根据所述应用程序源码及判断结果生成第一可执行文件,所述第一可执行文件包括使用所述特性检测指令获取处理器特性信息的二进制码。S203, when it is not necessary to perform the first detection and it is clear that the first processor supports the characteristic detection instruction, generate a first executable file according to the application source code and the judgment result, and the first executable file A binary code for obtaining processor characteristic information using the characteristic detection instruction is included.

具体的,当根据第一特性参数判定运行编译的应用程序的第一处理器不需要进行第一检测,且根据第一特性参数明确所述第一处理器支持特性检测指令时,则无需再检测它的特性检测指令支持情况,可以直接确定它在执行特性检测指令时不会因为兼容问题发生崩溃,因此,选择检测速度快的特性检测指令来对第一处理器进行特性检测,以获取第一处理器所支持的特性信息。可以将特性检测指令的源码加入应用程序的源码进行编译,生成第一可执行文件,当第一处理器运行第一可执行文件时会直接执行该特性检测指令,在执行特性检测指令的过程中得到第一处理器所支持的特性信息。Specifically, when it is determined according to the first characteristic parameter that the first processor running the compiled application program does not need to perform the first detection, and it is clarified according to the first characteristic parameter that the first processor supports the characteristic detection instruction, no further detection is required. The support of its feature detection instruction can directly determine that it will not crash due to compatibility issues when executing the feature detection instruction. Feature information supported by the processor. The source code of the characteristic detection instruction can be added to the source code of the application program for compilation to generate a first executable file. When the first processor runs the first executable file, the characteristic detection instruction will be directly executed. In the process of executing the characteristic detection instruction Obtain feature information supported by the first processor.

S204,当需要进行所述第一检测时,根据所述应用程序源码及判断结果生成第二可执行文件,以使所述第一处理器在运行所述第二可执行文件时确定所述第一处理器是否支持所述特性检测指令并根据所述确定结果获取处理器特性信息。S204, when the first detection needs to be performed, generate a second executable file according to the application source code and the judgment result, so that the first processor determines the first executable file when running the second executable file Whether a processor supports the characteristic detection instruction and obtains processor characteristic information according to the determination result.

需要说明的是,当需要对第一处理器进行第一检测时,说明不确定第一处理器是否支持特性检测指令,因此,需要进一步对第一处理器进行第一检测,以确定第一处理器对于所述特性检测指令的支持情况,避免在第一处理器不支持特性检测指令的情况下强制其执行特性检测指令而发生崩溃。It should be noted that when the first detection needs to be performed on the first processor, it means that it is uncertain whether the first processor supports the characteristic detection instruction. Therefore, it is necessary to further perform the first detection on the first processor to determine the first processing. The state of the processor's support for the characteristic detection instruction, so as to avoid the crash caused by forcing the first processor to execute the characteristic detection instruction under the condition that the first processor does not support the characteristic detection instruction.

一些实施例中,根据所述应用程序源码及判断结果生成第二可执行文件,第一处理器在运行所述第二可执行文件对第一处理器进行第一检测的方法可以包含两种,一种是通过获取第一处理器的特定标志位的值来判断第一处理器是否支持特性检测指令,但是这种方法对处理器的版本有要求,有些版本的处理器没有特殊标志位,因此无法采用这种方法来确定;另一种是较为通用的方法,对于处理器的版本没有要求,具体为:通过在第一处理器运行应用程序进程之外,创建一个子进程,在子进程中单独执行特性检测指令,通过监控子进程的执行情况来确定第一处理器是否支持特性检测指令。In some embodiments, the second executable file is generated according to the source code of the application program and the judgment result, and the first processor runs the second executable file to perform the first detection on the first processor, which may include two methods. One is to determine whether the first processor supports the feature detection instruction by obtaining the value of the specific flag bit of the first processor, but this method has requirements for the version of the processor. Some versions of the processor do not have special flag bits, so This method cannot be used to determine; the other is a more general method, which has no requirements for the version of the processor, specifically: by creating a child process outside the first processor running the application process, in the child process The characteristic detection instruction is executed independently, and whether the first processor supports the characteristic detection instruction is determined by monitoring the execution of the subprocess.

更进一步的,通过对第一处理器进行第一检测的结果,来确定获取第一处理器所支持特性信息的方式,若通过第一检测确定第一处理器支持特性检测指令,则采用检测速度较快的特性检测指令来获取第一处理器支持的特性信息;若通过第一检测确定第一处理器不支持特性检测指令,则通过读取cpuinfo文件获取第一处理器支持的特性信息,避免第一处理器强制执行特性检测指令而崩溃。Further, the method of obtaining the feature information supported by the first processor is determined by the result of the first detection on the first processor. If it is determined through the first detection that the first processor supports the feature detection instruction, the detection speed is adopted. Faster feature detection instruction to obtain feature information supported by the first processor; if it is determined through the first detection that the first processor does not support the feature detection instruction, the feature information supported by the first processor is obtained by reading the cpuinfo file to avoid The first processor crashes by forcing a feature detection instruction.

本实施例中,通过在编译应用程序时先获取第一特性参数,通过第一特性参数来判断运行该应用程序的第一处理器是否需要进行第一检测,第一检测即判断第一处理器是否支持特性检测指令,若不需要对第一处理器进行第一检测,则说明第一处理器已明确支持特性检测指令或已明确不支持特性检测指令,对于已经明确支持特性检测指令的第一处理器,则生成第一可执行文件,第一可执行文件包括使用所述特性检测指令获取处理器特性信息的二进制码,第一处理器运行第一可执行文件便可以直接使用检测速度更快的特性检测指令的方式检测其所支持的特性信息,为明确知道处理器支持特性检测指令的场合提供一条最快速的特性检查方法,不用所有的场合都去先检查是否支持特性检查指令。若需要对第一处理器进行第一检测,则说明不确定第一处理器是否支持特性检测指令,因此,生成第二可执行文件,第一处理器在运行第二可执行文件的同时确定第一处理器是否支持所述特性检测指令并根据所述确定结果获取处理器特性信息。对于不明确处理器是否支持特性检测指令的情况,先确定第一处理器是否支持特性检测指令,根据确定结果选择特性检测方法,从而在避免了第一处理器在不支持特性检测指令的情况下盲目对其进行特性检测导致的崩溃情况,能够在保证处理器不出现崩溃的情况下,用最快速的方式实现处理器特性检测,提高了特性检测效率。In this embodiment, the first characteristic parameter is obtained when compiling the application program, and the first characteristic parameter is used to determine whether the first processor running the application program needs to perform the first detection, and the first detection is to determine the first processor Whether the feature detection command is supported, if the first detection is not required for the first processor, it means that the first processor has explicitly supported the feature detection command or has clearly not supported the feature detection command. For the first processor that has explicitly supported the feature detection command The processor generates a first executable file, and the first executable file includes the binary code for obtaining the processor feature information using the feature detection instruction, and the first processor can directly use the first executable file to detect faster by running the first executable file. It detects the feature information it supports by means of the feature check instruction, and provides the fastest feature check method for the occasions where it is clear that the processor supports the feature check command. It is not necessary to check whether the feature check command is supported in all occasions. If it is necessary to perform the first detection on the first processor, it means that it is uncertain whether the first processor supports the feature detection instruction. Therefore, a second executable file is generated, and the first processor determines the first executable file while running the second executable file. Whether a processor supports the characteristic detection instruction and obtains processor characteristic information according to the determination result. In the case where it is unclear whether the processor supports the feature detection command, first determine whether the first processor supports the feature detection command, and select the feature detection method according to the determination result, so as to avoid the situation that the first processor does not support the feature detection command The crash situation caused by blindly performing feature detection on it can realize the processor feature detection in the fastest way under the condition of ensuring that the processor does not crash, which improves the feature detection efficiency.

为了更清楚的理解本申请,下面将在图2所示实施例基础上,结合图3对处理器的特性检测方法的完整实现过程进行详细描述。For a clearer understanding of the present application, the complete implementation process of the processor characteristic detection method will be described in detail below based on the embodiment shown in FIG. 2 and in conjunction with FIG. 3 .

如图3所示,本实施例提供的方法可以包括以下步骤。As shown in FIG. 3 , the method provided in this embodiment may include the following steps.

S31,在编译应用程序时,获取第一特性参数。S31, when compiling the application program, obtain the first characteristic parameter.

S32,根据所述第一特性参数,判断运行该应用程序的第一处理器是否需要进行第一检测,所述第一检测为检测所述第一处理器是否支持特性检测指令。S32: Determine, according to the first characteristic parameter, whether the first processor running the application needs to perform a first detection, where the first detection is to detect whether the first processor supports a characteristic detection instruction.

其中,第一特性参数用来标识相应的处理器是否明确支持特性检测指令。The first characteristic parameter is used to identify whether the corresponding processor explicitly supports the characteristic detection instruction.

具体的,技术人员在配置处理器时,很多都知道自己配置的处理器是否支持特性检测指令,因此,技术人员可以预先通过操作终端在处理器中设置一些特性参数,通过特性参数来标识处理器是否明确支持特性检测指令。Specifically, when configuring a processor, many technicians know whether the processor they configure supports the feature detection command. Therefore, the technician can set some feature parameters in the processor through the operation terminal in advance, and identify the processor by the feature parameter. Whether to explicitly support feature detection directives.

在一种可能的实施例中,技术人员可以在明确支持或明确不支持特性检测指令的处理器中设置不同特性检测参数的数值,对于不明确是否支持特性检测指令的处理器中不设置特性检测参数。在第一处理器运行编译的应用程序时,先获取第一处理器的第一特性参数,若存在第一特性参数,则说明第一处理器明确支持或明确不支持特性检测指令,然后进一步根据获取到的第一特性参数的数值来判断第一处理器是明确支持特性检测指令,还是明确不支持特性检测指令,比如,可以用特性参数00来标识处理器明确支持特性检测指令,用特性参数01来标识处理器明确不支持特性检测指令,因此不需要对第一处理器进行第一检测;若不存在第一特性参数,则说明不确定第一处理器是否支持特性检测指令,为了选择快速且安全的特性检测方式,则需要对第一处理器进行第一检测,以检测第一处理器是否支持特性检测指令。In a possible embodiment, a technician may set the values of different feature detection parameters in processors that explicitly support or explicitly do not support feature detection instructions, and do not set feature detection for processors that do not explicitly support feature detection instructions. parameter. When the first processor runs the compiled application program, it first obtains the first characteristic parameter of the first processor. If the first characteristic parameter exists, it means that the first processor explicitly supports or explicitly does not support the characteristic detection instruction, and then further according to The obtained value of the first feature parameter is used to determine whether the first processor explicitly supports the feature detection command or does not explicitly support the feature detection command. For example, the feature parameter 00 can be used to indicate that the processor explicitly supports the feature detection command, and the feature parameter 01 to indicate that the processor clearly does not support the feature detection command, so it is not necessary to perform the first detection on the first processor; if there is no first feature parameter, it means that it is uncertain whether the first processor supports the feature detection command. In addition, in a safe feature detection method, a first detection needs to be performed on the first processor to detect whether the first processor supports the feature detection instruction.

示例性的,假设待检测的处理器有四个,分别为处理器A、处理器B、处理器C和处理器D,其中,处理器A、处理器B和处理器D是检测技术人员配置的,检测技术人员知道处理器A和B支持特性检测指令,处理器D不支持特性检测指令,而处理器C不是该检测技术人员配置的,其不知道处理器C是否能够支持特性检测指令。因此检测技术人员可以预先通过操作终端在处理器A和处理器B中设置特性参数为00,在处理器D中设置特性参数为01,在处理器C中不设置特性参数。当处理器A、B、C和D分别运行编译的应用程序时能够获取到处理器A和B的特性参数00则说明处理器A和B明确支持特性检测指令,获取到处理器D的特性参数为01则说明处理器明确不支持特性检测指令,但是获取不到处理器C的特性参数,则说明处理器C不能确定是否支持特性检测指令,因此不可以直接使用特性检测指令来检测处理器C的特性,需要对处理器C进行第一检测,以检测处理器C是否支持特性检测指令。Exemplarily, it is assumed that there are four processors to be detected, namely processor A, processor B, processor C, and processor D, wherein processor A, processor B, and processor D are configured by inspection technicians. Yes, the testing technician knows that processors A and B support feature testing instructions, processor D does not support feature testing instructions, and processor C is not configured by the testing technician, so he does not know whether processor C can support feature testing instructions. Therefore, the testing technician can set the characteristic parameter to 00 in processor A and processor B in advance through the operation terminal, set the characteristic parameter to 01 in processor D, and set no characteristic parameter in processor C. When processors A, B, C, and D run the compiled application programs respectively, the characteristic parameters of processors A and B can be obtained. 00 means that processors A and B explicitly support the characteristic detection instruction, and the characteristic parameters of processor D are obtained. If it is 01, it means that the processor clearly does not support the feature detection command, but the feature parameters of the processor C cannot be obtained, which means that the processor C cannot determine whether it supports the feature detection command. Therefore, the feature detection command cannot be used directly to detect the processor C. feature, it is necessary to perform a first detection on the processor C to detect whether the processor C supports the feature detection instruction.

在另一种可能的实施例中,技术人员可以分别在明确支持或明确不支持特性检测指令的处理器和不明确是否支持特性检测指令的处理器中设置数值不同的特性参数,处理器在运行编译的应用程序时根据获取到的特性参数的数值,来确定处理器是否进行第一检测。可选的,用特性参数00标识处理器明确支持特性检测指令,用特性参数01来标识处理器明确不支持特性检测指令,用特性参数10标识处理器不能直接使用特性检测指令,需要进行第一检测以进一步判断其是否支持特性检测指令。当第一处理器运行编译的应用程序时,若获取到的第一处理器的特性参数为00,则说明第一处理器明确支持特性检测指令,若获取到的第一处理器的特性参数为01,则说明第一处理器明确不支持特性检测指令,不需要对第一处理器进行第一检测;若获取到的第一处理器的特性参数为10,则说明不明确第一处理器是否支持特性检测指令,需要对第一处理器进行第一检测。In another possible embodiment, a technical person may set characteristic parameters with different values in the processor that explicitly supports or explicitly does not support the characteristic detection instruction and the processor that does not explicitly support the characteristic detection instruction. When compiling the application program, it is determined whether the processor performs the first detection according to the acquired value of the characteristic parameter. Optionally, use the characteristic parameter 00 to indicate that the processor explicitly supports the characteristic detection instruction, use the characteristic parameter 01 to indicate that the processor explicitly does not support the characteristic detection instruction, and use the characteristic parameter 10 to indicate that the processor cannot directly use the characteristic detection instruction, and the first step is required. Check to further determine whether it supports the feature detection command. When the first processor runs the compiled application, if the acquired characteristic parameter of the first processor is 00, it means that the first processor explicitly supports the characteristic detection instruction. If the acquired characteristic parameter of the first processor is 01, it means that the first processor clearly does not support the characteristic detection instruction, and it is not necessary to perform the first detection on the first processor; if the acquired characteristic parameter of the first processor is 10, it means that it is unclear whether the first processor is To support the feature detection instruction, the first detection needs to be performed on the first processor.

S33,当不需要进行所述第一检测且明确所述第一处理器支持所述特性检测指令时,根据所述应用程序源码及判断结果生成第一可执行文件,以使所述第一处理器运行所述第一可执行文件。S33, when the first detection is not required and it is clear that the first processor supports the characteristic detection instruction, generate a first executable file according to the application source code and the judgment result, so as to enable the first processing The first executable file is executed by the server.

其中,所述第一可执行文件包括直接使用所述特性检测指令获取处理器特性信息的二进制码。Wherein, the first executable file includes a binary code that directly uses the characteristic detection instruction to obtain processor characteristic information.

具体的,当根据第一特性参数判定运行编译的应用程序的第一处理器不需要进行第一检测,且根据第一特性参数明确所述第一处理器支持特性检测指令时,则无需再检测它的特性检测指令支持情况,可以直接确定它在执行特性检测指令时不会因为兼容问题发生崩溃,因此,选择检测速度快的特性检测指令来对第一处理器进行特性检测,以获取第一处理器所支持的特性信息。Specifically, when it is determined according to the first characteristic parameter that the first processor running the compiled application program does not need to perform the first detection, and it is clarified according to the first characteristic parameter that the first processor supports the characteristic detection instruction, no further detection is required. The support of its feature detection instruction can directly determine that it will not crash due to compatibility issues when executing the feature detection instruction. Feature information supported by the processor.

在一种可能的实施例中,对于可以将特性检测指令的源码加入应用程序的源码进行编译,生成第一可执行文件,当第一处理器运行第一可执行文件时会直接执行该特性检测指令,在执行特性检测指令的过程中得到第一处理器所支持的特性信息。In a possible embodiment, the source code of the characteristic detection instruction can be added to the source code of the application program for compilation to generate a first executable file, and the characteristic detection is directly executed when the first processor runs the first executable file The instruction is to obtain characteristic information supported by the first processor in the process of executing the characteristic detection instruction.

在本实施例一种可能的情况下,第一处理器运行第一可执行文件时执行的步骤如图4所示,包括:S331,第一处理器运行所述第一可执行文件,以在运行所述第一可执行文件时执行所述特性检测指令。S332,获取执行所述特性检测指令时生成的特性标识。S333,解析所述特性标识,得到所述第一处理器支持的特性信息。In a possible situation in this embodiment, the steps performed when the first processor runs the first executable file are shown in FIG. 4 , including: S331, the first processor runs the first executable file to The characteristic detection instruction is executed when the first executable file is run. S332: Acquire the characteristic identifier generated when the characteristic detection instruction is executed. S333: Parse the feature identifier to obtain feature information supported by the first processor.

S34,当不需要进行所述第一检测且明确所述第一处理器不支持所述特性检测指令时,根据所述应用程序源码及判断结果生成第三可执行文件,以使所述第一处理器运行所述第三可执行文件。S34, when it is not necessary to perform the first detection and it is clear that the first processor does not support the characteristic detection instruction, generate a third executable file according to the application source code and the judgment result, so that the first The processor runs the third executable file.

其中,所述第三可执行文件包括读取cpuinfo文件获取处理器特性信息的二进制码。Wherein, the third executable file includes binary code for obtaining processor characteristic information by reading the cpuinfo file.

需要说明的是,当根据第一特性参数判定运行编译的应用程序的第一处理器不需要进行第一检测,且根据第一特性参数明确所述第一处理器不支持特性检测指令时,则无需再检测它的特性检测指令支持情况,如果直接用特性检测指令来检测特性信息会造成第一处理器运行应用程序的过程发生崩溃,导致应用程序无法正常运行。因此,选择较为安全的检测方式来检测第一处理器的特性信息。It should be noted that, when it is determined according to the first characteristic parameter that the first processor running the compiled application does not need to perform the first detection, and it is determined according to the first characteristic parameter that the first processor does not support the characteristic detection instruction, then There is no need to check its feature detection instruction support. If the feature detection instruction is directly used to detect feature information, the process of running the application program on the first processor will crash, resulting in the application program not running normally. Therefore, a safer detection method is selected to detect the characteristic information of the first processor.

具体的,可以读取cpuinfo文件这一过程对于的代码加入应用程序的源码进行编译,生成第三可执行文件,从而使得第三可执行文件中包括读取cpuinfo文件获取处理器特性信息的二进制码,当第一处理器运行第三可执行文件时会先读取第一处理器对应的cpuinfo文件,然后解析cpuinfo文件得到所述第一处理器支持的特性信息。Specifically, in the process of reading the cpuinfo file, the code added to the source code of the application program is compiled to generate a third executable file, so that the third executable file includes the binary code for reading the cpuinfo file to obtain the processor characteristic information , when the first processor runs the third executable file, it will first read the cpuinfo file corresponding to the first processor, and then parse the cpuinfo file to obtain feature information supported by the first processor.

在本实施例一种可能的情况下,第一处理器运行第三可执行文件时执行的步骤如图6所示,包括:S341,第一处理器运行所述第三可执行文件;S342,读取cpuinfo文件;S343,解析cpuinfo文件得到所述第一处理器支持的特性信息。In a possible case of this embodiment, the steps performed when the first processor runs the third executable file are shown in FIG. 6 , including: S341, the first processor runs the third executable file; S342, Read the cpuinfo file; S343, parse the cpuinfo file to obtain feature information supported by the first processor.

S35,当需要进行所述第一检测时,根据所述应用程序源码及判断结果生成第二可执行文件,以使所述第一处理器在运行所述第二可执行文件时确定所述第一处理器是否支持所述特性检测指令并根据所述确定结果获取处理器特性信息。S35, when the first detection needs to be performed, generate a second executable file according to the application source code and the judgment result, so that the first processor determines the first executable file when running the second executable file Whether a processor supports the characteristic detection instruction and obtains processor characteristic information according to the determination result.

需要说明的是,当需要对第一处理器进行第一检测时,说明不确定第一处理器是否支持特性检测指令,因此,需要进一步对第一处理器进行第一检测,以确定第一处理器对于所述特性检测指令的支持情况,避免在第一处理器不支持特性检测指令的情况下强制其执行特性检测指令而发生崩溃。It should be noted that when the first detection needs to be performed on the first processor, it means that it is uncertain whether the first processor supports the characteristic detection instruction. Therefore, it is necessary to further perform the first detection on the first processor to determine the first processing. The state of the processor's support for the characteristic detection instruction, so as to avoid the crash caused by forcing the first processor to execute the characteristic detection instruction under the condition that the first processor does not support the characteristic detection instruction.

一些实施例中,如图5所示,第二可执行文件的运行流程包括如下步骤:In some embodiments, as shown in FIG. 5 , the running process of the second executable file includes the following steps:

S351,对第一处理器进行第一检测,以确定所述第一处理器是否支持特性检测指令,若确定结果为是,则进入步骤S352~S354;若确定结果为否,则进入步骤S355~S356。S351, perform a first detection on the first processor to determine whether the first processor supports the feature detection instruction, if the determination result is yes, then proceed to steps S352-S354; if the determination result is no, proceed to steps S355- S356.

一些实施例中,对第一处理器进行第一检测的方法可以包含两种,一种是通过获取第一处理器的特定标志位的值来判断第一处理器是否支持特性检测指令,但是这种方法对处理器的版本有要求,有些版本的处理器没有特殊标志位,因此无法采用这种方法来确定。比如,对于8086和8088CPU,其标志位仅有16位长,没有保留特殊标志位来标识其是否支持特性检测指令,而在80386CPU中,第21位(bit 21)保留未使用,若其支持特殊检测指令,则bit 21的值为1,因此,通过读取bit 21的值便可以确定是否支持特性检测指令。In some embodiments, the first detection method for the first processor may include two methods. One is to determine whether the first processor supports the feature detection instruction by obtaining the value of a specific flag bit of the first processor. This method has requirements on the version of the processor. Some versions of the processor do not have special flag bits, so this method cannot be used to determine. For example, for 8086 and 8088CPU, the flag bits are only 16 bits long, and no special flag bits are reserved to indicate whether they support feature detection instructions, while in 80386CPU, the 21st bit (bit 21) is reserved and unused, if it supports special If the command is detected, the value of bit 21 is 1. Therefore, by reading the value of bit 21, it can be determined whether the feature detection command is supported.

另一种是较为通用的方法,对于处理器的版本没有要求,具体为:通过在第一处理器运行应用程序进程之外,创建一个子进程,在子进程中单独执行特性检测指令,通过监控子进程的执行情况来确定第一处理器是否支持特性检测指令。具体为:第一处理器在运行编译的应用程序的进程(可称为父进程)时,额外创建一个子进程,控制第一处理器在该子进程中单独执行特性检测指令,若该子进程整个执行过程都能顺利进行,不会出现崩溃的现象,则说明第二处理器支持特性检测指令;若执行特性检测指令的过程出现崩溃的情况,导致子进程中断,则说明第一处理器不支持特性检测指令。The other is a more general method, there is no requirement for the version of the processor, specifically: by creating a sub-process in addition to the first processor running the application process, and executing the feature detection instruction in the sub-process separately, by monitoring The execution of the subprocess determines whether the first processor supports the feature detection instruction. Specifically: when the first processor runs the process of the compiled application program (which may be referred to as a parent process), an additional child process is created, and the first processor is controlled to execute the feature detection instruction independently in the child process. If the child process The entire execution process can be carried out smoothly, and no crash occurs, it means that the second processor supports the feature detection instruction; if the process of executing the feature detection instruction crashes, causing the child process to be interrupted, it means that the first processor does not. Supports feature detection commands.

在一种可能的实施例中,第一处理器在子进程中执行特性检测指令时,父进程实时读取子进程的运行状态,若直到子进程结束,父进程一直读取到的都是正常状态,则说明第一处理器支持特性检测指令;若父进程读取到子进程状态中断,则说明第一处理器不支持特性检测指令。In a possible embodiment, when the first processor executes the characteristic detection instruction in the child process, the parent process reads the running status of the child process in real time, and if the parent process reads the running state until the child process ends, the readings are normal. If the parent process reads the child process status interruption, it means that the first processor does not support the feature detection instruction.

在另一种可能的实施例中,在子进程中执行特性检测指令时,子进程主动向父进程反馈执行状态,若子进程出现中断则会向父进程反馈失败信息;若子进程能够完整执行结束,则会向父进程反馈成功信息,处理器在父进程中运行应用程序时便能判断是否支持特性检测指令。In another possible embodiment, when the feature detection instruction is executed in the child process, the child process actively feeds back the execution status to the parent process, and if the child process is interrupted, it feeds back failure information to the parent process; if the child process can complete the execution, The success information will be fed back to the parent process, and the processor can determine whether to support the feature detection command when running the application in the parent process.

S352,控制所述第一处理器执行所述特性检测指令。S352: Control the first processor to execute the characteristic detection instruction.

S353,获取执行所述特性检测指令时生成的特性标识。S353: Acquire the characteristic identifier generated when the characteristic detection instruction is executed.

S354,解析所述特性标识,得到所述第一处理器支持的特性信息。S354: Parse the feature identifier to obtain feature information supported by the first processor.

具体的,通过对第一处理器进行第一检测的结果,来确定获取第一处理器所支持特性信息的方式,若通过第一检测确定第一处理器支持特性检测指令,则采用检测速度较快的特性检测指令来获取第一处理器支持的特性信息,步骤S352~S354即对应第一可执行程序的运行过程。Specifically, the method of acquiring the feature information supported by the first processor is determined by the result of the first detection on the first processor. The fast characteristic detection instruction is used to obtain characteristic information supported by the first processor. Steps S352 to S354 correspond to the running process of the first executable program.

S355,读取cpuinfo文件。S355, read the cpuinfo file.

S356,解析cpuinfo文件,得到所述第一处理器支持的特性信息。S356, parse the cpuinfo file to obtain feature information supported by the first processor.

具体的,若通过第一检测确定第一处理器不支持特性检测指令,则通过读取cpuinfo文件获取第一处理器支持的特性信息,避免第一处理器强制执行特性检测指令而崩溃。步骤S355~S356即对应运行第三可执行程序的过程。Specifically, if it is determined through the first detection that the first processor does not support the characteristic detection instruction, the characteristic information supported by the first processor is obtained by reading the cpuinfo file, so as to avoid the crash of the first processor forcibly executing the characteristic detection instruction. Steps S355 to S356 correspond to the process of running the third executable program.

图7是本发明一示例性实施例示出的处理器的特性检测装置的结构示意图。FIG. 7 is a schematic structural diagram of an apparatus for detecting characteristics of a processor according to an exemplary embodiment of the present invention.

如图7所示,本实施例提供的装置包括:获取模块701,判断模块702和检测模块703;获取模块701,用于在编译应用程序时,获取第一特性参数;判断模块702,用于根据所述第一特性参数,判断运行该应用程序的第一处理器是否需要进行第一检测,所述第一检测为检测所述第一处理器是否支持特性检测指令;检测模块703,用于当不需要进行所述第一检测且明确所述第一处理器支持所述特性检测指令时,根据所述应用程序源码及判断结果生成第一可执行文件,所述第一可执行文件包括直接使用所述特性检测指令获取处理器特性信息的二进制码;所述检测模块还用于当需要进行所述第一检测时,根据所述应用程序源码及判断结果生成第二可执行文件,以使所述第一处理器在运行所述第二可执行文件时确定所述第一处理器是否支持所述特性检测指令并根据所述确定结果进行处理器特性信息获取。As shown in FIG. 7 , the apparatus provided in this embodiment includes: an acquisition module 701 , a judgment module 702 and a detection module 703 ; the acquisition module 701 is used to acquire the first characteristic parameter when compiling the application program; the judgment module 702 is used to According to the first characteristic parameter, it is judged whether the first processor running the application needs to perform the first detection, and the first detection is to detect whether the first processor supports the characteristic detection instruction; the detection module 703 is used for When it is not necessary to perform the first detection and it is clear that the first processor supports the characteristic detection instruction, a first executable file is generated according to the application source code and the judgment result, and the first executable file includes a direct Use the characteristic detection instruction to obtain the binary code of the processor characteristic information; the detection module is also used to generate a second executable file according to the application source code and the judgment result when the first detection needs to be performed, so that the The first processor determines whether the first processor supports the characteristic detection instruction when running the second executable file, and acquires processor characteristic information according to the determination result.

进一步的,所述检测模块还用于:Further, the detection module is also used for:

当不需要进行所述第一检测且明确所述第一处理器不支持所述特性检测指令时,根据所述应用程序源码及判断结果生成第三可执行文件,所述第三可执行文件包括读取cpuinfo文件获取处理器特性信息的二进制码。When it is not necessary to perform the first detection and it is clear that the first processor does not support the characteristic detection instruction, a third executable file is generated according to the application source code and the judgment result, and the third executable file includes Read the cpuinfo file to obtain the binary code of processor characteristic information.

进一步,所述检测模块具体用于:Further, the detection module is specifically used for:

若确定所述第一处理器支持所述特性检测指令,则使用所述特性检测指令获取处理器特性信息;If it is determined that the first processor supports the characteristic detection instruction, use the characteristic detection instruction to obtain processor characteristic information;

若确定所述第一处理器不支持所述特性检测指令,则读取cpuinfo文件获取处理器特性信息。If it is determined that the first processor does not support the characteristic detection instruction, read the cpuinfo file to obtain processor characteristic information.

进一步的,如图8所示,所述检测模块703包括:Further, as shown in FIG. 8 , the detection module 703 includes:

第一控制单元7031,用于控制所述第一处理器运行所述第一可执行文件,以在运行所述第一可执行文件时执行所述特性检测指令;a first control unit 7031, configured to control the first processor to run the first executable file, so as to execute the characteristic detection instruction when running the first executable file;

获取单元7032,用于获取执行所述特性检测指令时生成的特性标识;an acquisition unit 7032, configured to acquire the characteristic identifier generated when the characteristic detection instruction is executed;

第一解析单元7033,用于解析所述特性标识,得到所述第一处理器支持的特性信息。A first parsing unit 7033, configured to parse the feature identifier to obtain feature information supported by the first processor.

进一步的,所述检测模块包括:第二控制单元7034,用于控制所述第一处理器运行所述第三可执行文件;Further, the detection module includes: a second control unit 7034, configured to control the first processor to run the third executable file;

读取单元7035,用于在所述第一处理器运行所述第三可执行文件时读取cpuinfo文件;A reading unit 7035, configured to read the cpuinfo file when the first processor runs the third executable file;

第二解析单元7036,用于解析所述cpuinfo文件,得到所述第一处理器支持的特性信息。The second parsing unit 7036 is configured to parse the cpuinfo file to obtain feature information supported by the first processor.

本实施例中各个模块的详细功能描述请参考有关该方法的实施例中的描述,此处不做详细阐述说明。For the detailed functional description of each module in this embodiment, please refer to the description in the embodiment of the method, and no detailed description is given here.

图9为本发明实施例提供的电子设备的硬件结构示意图。如图9所示,本实施例提供的电子设备900包括:至少一个处理器901和存储器902。其中,处理器901、存储器902通过总线903连接。FIG. 9 is a schematic diagram of a hardware structure of an electronic device according to an embodiment of the present invention. As shown in FIG. 9 , the electronic device 900 provided in this embodiment includes: at least one processor 901 and a memory 902 . The processor 901 and the memory 902 are connected through a bus 903 .

在具体实现过程中,至少一个处理器901执行所述存储器902存储的计算机执行指令,使得至少一个处理器901执行上述方法实施例中的处理器的特性检测方法。In a specific implementation process, the at least one processor 901 executes the computer-executed instructions stored in the memory 902, so that the at least one processor 901 executes the method for detecting the characteristics of the processor in the foregoing method embodiments.

处理器901的具体实现过程可参见上述方法实施例,其实现原理和技术效果类似,本实施例此处不再赘述。For the specific implementation process of the processor 901, reference may be made to the foregoing method embodiments, and the implementation principles and technical effects thereof are similar, and details are not described herein again in this embodiment.

在上述的图9所示的实施例中,应理解,处理器可以是中央处理单元(英文:Central Processing Unit,简称:CPU),还可以是其他通用处理器、数字信号处理器(英文:Digital Signal Processor,简称:DSP)、专用集成电路(英文:Application SpecificIntegrated Circuit,简称:ASIC)等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合发明所公开的方法的步骤可以直接体现为硬件处理器执行完成,或者用处理器中的硬件及软件模块组合执行完成。In the above-mentioned embodiment shown in FIG. 9 , it should be understood that the processor may be a central processing unit (English: Central Processing Unit, CPU for short), or other general-purpose processors, digital signal processors (English: Digital Signal Processor) Signal Processor, referred to as DSP), application specific integrated circuit (English: Application Specific Integrated Circuit, referred to as: ASIC) and the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in conjunction with the invention can be directly embodied as executed by a hardware processor, or executed by a combination of hardware and software modules in the processor.

存储器可能包含高速RAM存储器,也可能还包括非易失性存储NVM,例如至少一个磁盘存储器。The memory may include high-speed RAM memory, and may also include non-volatile storage NVM, such as at least one disk memory.

总线可以是工业标准体系结构(Industry Standard Architecture,ISA)总线、外部设备互连(Peripheral Component Interconnect,PCI)总线或扩展工业标准体系结构(Extended Industry Standard Architecture,EISA)总线等。总线可以分为地址总线、数据总线、控制总线等。为便于表示,本申请附图中的总线并不限定仅有一根总线或一种类型的总线。The bus may be an Industry Standard Architecture (Industry Standard Architecture, ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (Extended Industry Standard Architecture, EISA) bus, or the like. The bus can be divided into address bus, data bus, control bus and so on. For convenience of representation, the buses in the drawings of the present application are not limited to only one bus or one type of bus.

本申请的另一实施例提供一种计算机可读存储介质,所述计算机可读存储介质中存储有计算机执行指令,当处理器执行所述计算机执行指令时,实现上述方法实施例中的处理器的特性检测方法。Another embodiment of the present application provides a computer-readable storage medium, where computer-executable instructions are stored in the computer-readable storage medium, and when a processor executes the computer-executable instructions, the processor in the foregoing method embodiment is implemented characteristic detection method.

上述的计算机可读存储介质,上述可读存储介质可以是由任何类型的易失性或非易失性存储设备或者它们的组合实现,如静态随机存取存储器(SRAM),电可擦除可编程只读存储器(EEPROM),可擦除可编程只读存储器(EPROM),可编程只读存储器(PROM),只读存储器(ROM),磁存储器,快闪存储器,磁盘或光盘。可读存储介质可以是通用或专用计算机能够存取的任何可用介质。The above-mentioned computer-readable storage medium, the above-mentioned readable storage medium can be realized by any type of volatile or non-volatile storage device or their combination, such as static random access memory (SRAM), electrically erasable Programmable Read Only Memory (EEPROM), Erasable Programmable Read Only Memory (EPROM), Programmable Read Only Memory (PROM), Read Only Memory (ROM), Magnetic Memory, Flash Memory, Magnetic or Optical Disk. A readable storage medium can be any available medium that can be accessed by a general purpose or special purpose computer.

一种示例性的可读存储介质耦合至处理器,从而使处理器能够从该可读存储介质读取信息,且可向该可读存储介质写入信息。当然,可读存储介质也可以是处理器的组成部分。处理器和可读存储介质可以位于专用集成电路(Application Specific IntegratedCircuits,简称:ASIC)中。当然,处理器和可读存储介质也可以作为分立组件存在于设备中。An exemplary readable storage medium is coupled to the processor such that the processor can read information from, and write information to, the readable storage medium. Of course, the readable storage medium can also be an integral part of the processor. The processor and the readable storage medium may be located in application specific integrated circuits (Application Specific Integrated Circuits, ASIC for short). Of course, the processor and the readable storage medium may also exist in the device as discrete components.

本领域普通技术人员可以理解:实现上述各方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成。前述的程序可以存储于一计算机可读取存储介质中。该程序在执行时,执行包括上述各方法实施例的步骤;而前述的存储介质包括:ROM、RAM、磁碟或者光盘等各种可以存储程序代码的介质。Those of ordinary skill in the art can understand that all or part of the steps of implementing the above method embodiments may be completed by program instructions related to hardware. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps including the above method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, magnetic disk or optical disk and other media that can store program codes.

最后应说明的是:以上各实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述各实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的范围。Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, but not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: The technical solutions described in the foregoing embodiments can still be modified, or some or all of the technical features thereof can be equivalently replaced; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the technical solutions of the embodiments of the present invention. scope.

Claims (10)

1. A method for detecting characteristics of a processor, comprising:
when an application program is compiled, acquiring a first characteristic parameter;
judging whether a first processor running the application program needs to perform first detection according to the first characteristic parameter, wherein the first detection is to detect whether the first processor supports a characteristic detection instruction;
when the first detection is not needed and the first processor is clear to support the characteristic detection instruction, generating a first executable file according to the source code of the application program and a judgment result, wherein the first executable file comprises a binary code for acquiring processor characteristic information by using the characteristic detection instruction;
when the first detection is needed, a second executable file is generated according to the source code of the application program and the judgment result, so that whether the first processor supports the characteristic detection instruction or not is determined when the first processor runs the second executable file, and processor characteristic information is obtained according to the determination result.
2. The method of claim 1, further comprising:
and when the first detection is not needed and it is clear that the first processor does not support the characteristic detection instruction, generating a third executable file according to the application program source code and the judgment result, wherein the third executable file comprises a binary code for reading the cpu info file to acquire the characteristic information of the processor.
3. The method of claim 1, wherein obtaining processor characterization information based on the determination comprises:
if the first processor is determined to support the characteristic detection instruction, acquiring processor characteristic information by using the characteristic detection instruction;
and if the first processor is determined not to support the characteristic detection instruction, reading a cpuinfo file to acquire processor characteristic information.
4. The method of any of claims 1-3, wherein said using said characteristic detection instructions to obtain processor characteristic information comprises:
control the first processor to execute the first executable file to execute the characteristic detection instructions while executing the first executable file;
acquiring a characteristic identifier generated when the characteristic detection instruction is executed;
and analyzing the characteristic identification to obtain the characteristic information supported by the first processor.
5. The method according to any one of claims 2 to 4, wherein the reading of the cpuinfo file to obtain the processor characteristic information comprises:
and controlling the first processor to run the third executable file so as to read and analyze the cpuinfo file when the third executable file is run, and obtaining the characteristic information supported by the first processor.
6. An apparatus for detecting characteristics of a processor, comprising:
the acquisition module is used for acquiring a first characteristic parameter when the application program is compiled;
the judging module is used for judging whether a first processor running the application program needs to perform first detection according to the first characteristic parameter, wherein the first detection is used for detecting whether the first processor supports a characteristic detection instruction;
a detection module, configured to generate a first executable file according to the source code of the application program and a determination result when the first detection is not required and it is clear that the first processor supports the characteristic detection instruction, where the first executable file includes a binary code that directly uses the characteristic detection instruction to obtain processor characteristic information;
the detection module is further configured to generate a second executable file according to the application source code and the determination result when the first detection is required, so that the first processor determines whether the first processor supports the characteristic detection instruction when running the second executable file, and acquires processor characteristic information according to the determination result.
7. The apparatus of claim 6, wherein the detection module is further configured to:
and when the first detection is not needed and it is clear that the first processor does not support the characteristic detection instruction, generating a third executable file according to the application program source code and the judgment result, wherein the third executable file comprises a binary code for reading the cpu info file to acquire the characteristic information of the processor.
8. The apparatus of claim 6, wherein the detection module is specifically configured to:
if the first processor is determined to support the characteristic detection instruction, acquiring processor characteristic information by using the characteristic detection instruction;
and if the first processor is determined not to support the characteristic detection instruction, reading a cpuinfo file to acquire processor characteristic information.
9. The apparatus of any of claims 6-8, wherein the detection module comprises:
a first control unit for controlling the first processor to execute the first executable file to execute the characteristic detection instruction when the first executable file is executed;
an acquisition unit configured to acquire a characteristic identifier generated when the characteristic detection instruction is executed;
and the first analysis unit is used for analyzing the characteristic identifier to obtain the characteristic information supported by the first processor.
10. The apparatus of any of claims 7-9, wherein the detection module comprises: the second control unit is used for controlling the first processor to run the third executable file;
a reading unit, configured to read a cpuinfo file when the first processor runs the third executable file;
and the second analysis unit is used for analyzing the cpuinfo file to obtain the characteristic information supported by the first processor.
CN202011568419.9A 2020-12-25 2020-12-25 Characteristic detection method and device of processor Pending CN114691434A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011568419.9A CN114691434A (en) 2020-12-25 2020-12-25 Characteristic detection method and device of processor

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011568419.9A CN114691434A (en) 2020-12-25 2020-12-25 Characteristic detection method and device of processor

Publications (1)

Publication Number Publication Date
CN114691434A true CN114691434A (en) 2022-07-01

Family

ID=82129055

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011568419.9A Pending CN114691434A (en) 2020-12-25 2020-12-25 Characteristic detection method and device of processor

Country Status (1)

Country Link
CN (1) CN114691434A (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060212688A1 (en) * 2005-03-18 2006-09-21 Shailender Chaudhry Generation of multiple checkpoints in a processor that supports speculative execution
CN102395051A (en) * 2011-11-07 2012-03-28 上海网达软件有限公司 Video player system, development method thereof and installation operation method thereof
CN104268076A (en) * 2014-09-23 2015-01-07 浪潮电子信息产业股份有限公司 Testing method suitable for automatically testing memory bandwidth of each processor platform
CN104317699A (en) * 2014-07-24 2015-01-28 小米科技有限责任公司 Application program verifying method and device
CN110457150A (en) * 2019-07-10 2019-11-15 锐捷网络股份有限公司 A kind of memory failure detection method and device
CN112083951A (en) * 2020-09-24 2020-12-15 中国人民解放军国防科技大学 Software package unified management method and system supporting multiple operating system platforms

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060212688A1 (en) * 2005-03-18 2006-09-21 Shailender Chaudhry Generation of multiple checkpoints in a processor that supports speculative execution
CN102395051A (en) * 2011-11-07 2012-03-28 上海网达软件有限公司 Video player system, development method thereof and installation operation method thereof
CN104317699A (en) * 2014-07-24 2015-01-28 小米科技有限责任公司 Application program verifying method and device
CN104268076A (en) * 2014-09-23 2015-01-07 浪潮电子信息产业股份有限公司 Testing method suitable for automatically testing memory bandwidth of each processor platform
CN110457150A (en) * 2019-07-10 2019-11-15 锐捷网络股份有限公司 A kind of memory failure detection method and device
CN112083951A (en) * 2020-09-24 2020-12-15 中国人民解放军国防科技大学 Software package unified management method and system supporting multiple operating system platforms

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
CUKER919: ""/proc/cpuinfo文件分析(查看CPU信息)"", 《CSDN博客:HTTPS://BLOG.CSDN.NET/CUKER919/ARTICLE/DETAILS/7635488》, 5 June 2012 (2012-06-05), pages 1 - 12 *
LEEHAMING: ""CPUID指令详解"", 《CSDN博客:HTTPS://BLOG.CSDN.NET/LEE_HAM/ARTICLE/DETAILS/103222475》, 24 November 2019 (2019-11-24), pages 1 - 7 *

Similar Documents

Publication Publication Date Title
US9027014B2 (en) Updating firmware compatibility data
US10049031B2 (en) Correlation of violating change sets in regression testing of computer software
CN109902005B (en) Automatic testing method and system
CN110688320B (en) Detection method, device and terminal equipment of global variables
CN103455397A (en) System self-test method, equipment and system
CN112162931A (en) Extraction and detection method, system, electronic equipment and storage medium
CN107329889B (en) A method of automatic testing of C compiler
CN111382077A (en) Application program crash reason positioning method and device, electronic equipment and storage medium
CN110069736A (en) Page loading method and equipment
CN103365772A (en) Device and method for software testing automatic evaluation
CN108089961A (en) One kind is based on MOC boards hardware reboot test methods and system
EP4492245A1 (en) Detecting an error in an updated software package by automatically rebuilding related downstream products
CN114691434A (en) Characteristic detection method and device of processor
CN109684205B (en) System testing method, device, electronic equipment and storage medium
US12386615B2 (en) Executing a continuous integration pipeline based on a type of change to source code
CN108614704B (en) Code compiling method and device
US20150007139A1 (en) Optimizing error parsing in an integrated development environment
CN116302543A (en) Continuous integration job processing method, device, equipment and storage medium
CN110908725A (en) Application program starting method and device, electronic equipment and readable medium
CN112559019B (en) Incremental file updating method and device
WO2022222499A1 (en) Code processing method, and system, cluster, medium and program product
CN112559370A (en) Front-end-based React project unit testing method and related equipment
CN113778505A (en) Component processing method and device
JP6724673B2 (en) Test support program, test support method, and test support device
JP6579022B2 (en) Generating program, generating method, and generating apparatus

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