Processor core number setting method, computer program product, device and medium
By obtaining and adapting the unit and total quantity information of the processor core, the problem of inaccurate number settings of the processor core is solved, and the minimum unit and minimum quantity settings of the core enablement are realized, which improves the stability and performance of the system.
Patent Information
- Application Number
- CN202411104750.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-13
- Publication Date
- 2024-11-19
- Estimated Expiration
- 2044-08-13
AI Technical Summary
The prior art is difficult to accurately set the number of processor cores, resulting in limited performance improvement.
By obtaining the target quantity value, the unit quantity information of the processor enabled core and the quantity value of all processors, it is adapted to enable cores in the processor, ensuring the minimum unit and minimum number of cores settings, and improving the accuracy of settings sex.
Improves the accuracy of the processor core number setting, ensures the minimum unit and minimum number of core enables, and improves the stability and performance of the system.
Smart Images

Figure CN118626158B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and more specifically, to a method for setting the number of processor cores, a computer program product, a device and a medium. Background Art
[0002] Currently, servers and other products support multiple processors, and each processor supports multiple cores, which makes the number of cores in the server larger, which provides a basis for improving the performance of the server. However, due to the limitations of the processor itself, there is a possibility that the setting fails when setting the number of cores.
[0003] In summary, how to accurately set the number of processor cores is a problem that currently needs to be solved urgently by those skilled in the art. Summary of the invention
[0004] The purpose of the present invention is to provide a method for setting the number of processor cores, which can solve the technical problem of how to accurately set the number of processor cores to a certain extent. The present invention also provides a computer program product, an electronic device and a computer-readable storage medium.
[0005] In a first aspect, the present invention provides a method for setting the number of processor cores, which is applied to a basic input and output system, comprising:
[0006] Obtaining a set target quantity value, the target quantity value comprising a quantity value of cores in a processor of an enabled target type;
[0007] Obtaining unit quantity information of processor-enabled cores of the target type;
[0008] Obtain a first quantity value of all processors of the target type;
[0009] determining a second number value of computing units in all processors of the target type, the computing units being used to host the cores;
[0010] The target quantity value is adapted to the unit quantity information, the first quantity value, and the second quantity value, and corresponding cores are enabled in all processors of the target type according to the adaptation result.
[0011] On the other hand, before adapting the target quantity value to the unit quantity information, the first quantity value, and the second quantity value, the method further includes:
[0012] Determining a total number of cores in all processors of the target type;
[0013] Detecting whether the target quantity value is greater than the total quantity value;
[0014] In response to the target quantity value being greater than the total quantity value, enabling cores corresponding to the total quantity value in all processors of the target type;
[0015] In response to the target quantity value being less than or equal to the total quantity value, a step of adapting the target quantity value to the unit quantity information, the first quantity value, and the second quantity value is performed.
[0016] On the other hand, obtaining unit quantity information of the target type of processor-enabled cores includes:
[0017] Unit quantity information of enabled cores of the processor of the target type is obtained, where the unit quantity information includes that cores are enabled in groups, and the number of cores in a group of cores is a third quantity value.
[0018] On the other hand, adapting the target quantity value to the unit quantity information, the first quantity value, and the second quantity value, and enabling corresponding cores in all processors of the target type according to the adaptation result, includes:
[0019] Detecting whether the target quantity value is greater than a first product value of the third quantity value and the second quantity value;
[0020] In response to the target quantity value being less than or equal to the first product value, enabling the second quantity value group of cores in all processors of the target type;
[0021] In response to the target quantity value being greater than the first product value, the target quantity value is adapted to the unit quantity information and the first quantity value, and corresponding cores are enabled in all processors of the target type according to the adaptation result.
[0022] On the other hand, adapting the target quantity value to the unit quantity information and the first quantity value, and enabling corresponding cores in all processors of the target type according to the adaptation result, includes:
[0023] generating a second product value of the third quantity value and the first quantity value;
[0024] generating a first remainder value by dividing the target quantity value by the second product value;
[0025] detecting whether the first remainder value is zero;
[0026] In response to the first remainder value being zero, a quotient of the target quantity value divided by the third quantity value is generated as a fourth quantity value, and the fourth quantity value group of cores is enabled in all processors of the target type.
[0027] On the other hand, after detecting whether the first remainder value is zero, the method further includes:
[0028] In response to the first remainder value being not zero, a prompt message indicating that the target quantity value is invalid is outputted.
[0029] On the other hand, enabling cores corresponding to the total number value in all processors of the target type includes:
[0030] A quotient of the total quantity value divided by the third quantity value is generated as a fifth quantity value, and the fifth quantity value group of cores is enabled in all processors of the target type.
[0031] On the other hand, obtaining unit quantity information of the target type of processor-enabled cores includes:
[0032] The unit quantity information of the enabled cores of the processor of the target type is obtained, where the unit quantity information includes the cores enabled in units.
[0033] On the other hand, adapting the target quantity value to the unit quantity information, the first quantity value, and the second quantity value, and enabling corresponding cores in all processors of the target type according to the adaptation result, includes:
[0034] Detecting whether the target quantity value is greater than the second quantity value;
[0035] In response to the target quantity value being less than or equal to the second quantity value, enabling the second quantity value of cores in all processors of the target type;
[0036] In response to the target quantity value being greater than the second quantity value, the target quantity value is adapted to the unit quantity information and the first quantity value, and corresponding cores are enabled in all processors of the target type according to the adaptation result.
[0037] On the other hand, adapting the target quantity value to the unit quantity information and the first quantity value, and enabling corresponding cores in all processors of the target type according to the adaptation result, includes:
[0038] generating a second remainder value by dividing the target quantity value by the first quantity value;
[0039] detecting whether the second remainder value is zero;
[0040] In response to the second remainder value being zero, enabling the target number of cores in all processors of the target type.
[0041] On the other hand, after detecting whether the second remainder value is zero, the method further includes:
[0042] In response to the second remainder value being not zero, a prompt message indicating that the target quantity value is invalid is outputted.
[0043] On the other hand, enabling cores corresponding to the total number value in all processors of the target type includes:
[0044] The total number of cores is enabled in all processors of the target type.
[0045] In a second aspect, the present invention provides a computer program product, comprising a computer program / instruction, which, when executed by a processor, implements the steps of any of the above-mentioned methods for setting the number of processor cores.
[0046] In a third aspect, the present invention provides an electronic device, comprising:
[0047] Memory for storing computer programs;
[0048] A processor is used to implement the steps of any of the above methods for setting the number of processor cores when executing the computer program.
[0049] In a fourth aspect, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the steps of any of the above methods for setting the number of processor cores are implemented.
[0050] A method for setting the number of processor cores provided by the present invention is applied to a basic input / output system, and obtains a set target number value, the target number value including the number value of cores in a processor of a target type being enabled; obtains unit number information of cores enabled in a processor of the target type; obtains a first number value of all processors of the target type; determines a second number value of computing units in all processors of the target type, the computing units being used to carry the cores; adapts the target number value to the unit number information, the first number value, and the second number value, and enables corresponding cores in all processors of the target type according to the adaptation result. The beneficial effect of the present invention is that after obtaining the target quantity value, the basic input and output system does not directly enable the target quantity value cores in all processors of the target type, but needs to adapt the target quantity value to the unit quantity information of the target type processor to enable the core, the first quantity value of all processors and the second quantity value of the computing unit, and enable the corresponding number of cores according to the adaptation result. Since the unit quantity information defines the minimum number of cores enabled each time, the first quantity value and the second quantity value define the minimum number of cores enabled by all processors of the target type, the present invention can determine the number value of cores that matches the minimum number of cores enabled each time and the minimum number of cores enabled by all processors according to the target quantity value to enable, thereby improving the accuracy of setting the number of processor cores. A computer program product, electronic device and computer-readable storage medium provided by the present invention also solve the corresponding technical problems. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0052] Figure 1 A flowchart of a method for setting the number of processor cores provided by an embodiment of the present invention;
[0053] Figure 2 A schematic diagram of the hardware architecture of the method for setting the number of processor cores in this application;
[0054] Figure 3 A flowchart for enabling cores in groups;
[0055] Figure 4 This is a flowchart for enabling cores in units;
[0056] Figure 5 A flowchart for enabling management of the core according to the bitmap;
[0057] Figure 6 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention;
[0058] Figure 7 Another structural schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0059] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments 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 creative work are within the scope of protection of the present invention.
[0060] See also Figure 1 , Figure 1 A flowchart of a method for setting the number of processor cores provided by an embodiment of the present invention.
[0061] A method for setting the number of processor cores provided by an embodiment of the present invention is applied to a basic input and output system and may include the following steps:
[0062] Step S101: obtaining a set target quantity value, where the target quantity value includes a quantity value of cores in a processor of an enabled target type.
[0063] In actual applications, the Basic Input Output System (BIOS) can first obtain a set target quantity value, such as a target quantity value set by a user, and the target quantity value refers to the value of the number of cores in a processor of a set enabled target type, and the value can be flexibly determined according to an application scenario, such as a fixed value such as 10 or 13, or a value determined according to processor performance requirements, etc.
[0064] Step S102: Obtain unit quantity information of enabled cores of a processor of the target type.
[0065] In actual applications, when a processor enables cores, there is a minimum unit. For example, some processors need to enable cores in modules (groups). Assuming that a group has 4 cores, the processor needs to enable 4 cores each time. In other words, the unit quantity information of the processor's enabled cores will affect the number of enabled cores of the processor, so it is necessary to obtain the unit quantity information of the target type of processor's enabled cores to perform compliance analysis on the target quantity value. It should be noted that after the unit quantity information is determined, each subsequent time a core is enabled, the corresponding core must be enabled with the unit quantity information as a constraint, that is, only an integer multiple of the unit quantity information can be enabled each time. Taking the unit quantity information as 4 as an example, only 4 or 8 cores can be enabled each time.
[0066] Step S103: Obtain a first quantity value of all processors of the target type.
[0067] In actual applications, considering that after a single processor is connected, at least the unit quantity information cores need to be enabled, the number of processors will also affect the number of processor cores that can be enabled. Therefore, it is necessary to obtain the first quantity value of all processors of the target type to perform compliance analysis on the target quantity value. It should be noted that the number of processors is limited by the device where the processor is located. For example, if the processor is located in a server, although the server can be installed with multiple types of processors, there is an upper limit on the number of each type of processor, which is also the first quantity value of the processor of that type.
[0068] Step S104: Determine a second quantity value of computing units in all processors of the target type, where the computing units are used to carry cores.
[0069] In practical applications, considering that in a single processor, the core is carried by the computing unit (Compute die), and each computing unit needs to enable the unit quantity information of each core, the number of computing units will also affect the number of enabled processor cores. Therefore, it is necessary to determine the second number of computing units in all processors of the target type to perform compliance analysis on the target number. It should be noted that the relationship between the processor and the computing unit can be flexibly determined according to the application scenario. For example, some processors have a single computing unit, and the number of processors is the second number. For example, some processors have two computing units, and the double value of the number of processors is the second number.
[0070] Step S105: adapting the target quantity value, the unit quantity information, the first quantity value and the second quantity value, and enabling corresponding cores in all processors of the target type according to the adaptation result.
[0071] In actual applications, after obtaining the unit quantity information, the first quantity value, and the second quantity value, the target quantity value can be adapted to the unit quantity information, the first quantity value, and the second quantity value, and the corresponding cores can be enabled in all processors of the target type according to the adaptation result. It should be noted that the target quantity value is adapted to the unit quantity information, the first quantity value, and the second quantity value, that is, a value that is an integer multiple of the unit quantity information, the first quantity value, and the second quantity value is determined according to the target quantity value, and the value of cores is enabled in all processors of the target type according to the unit quantity information, the first quantity value, and the second quantity value.
[0072] It should be noted that the connection relationship between the basic input and output system and the processor can be flexibly determined according to the application scenario. For example, when applied to a server, the hardware architecture of the method for setting the number of processor cores in this application can be as follows: Figure 2 As shown, the processor interacts with the basic input and output system through the serial peripheral interface (Serial Peripheral Interface, SPI), and the interaction process between the processor and the basic input and output system can include other contents in addition to the scheme of the present application, such as the basic input and output system can limit the frequency of the processor, etc.; the processor interacts with the baseboard management controller (Baseboard Management Controller) and the complex programmable logic device (Complex Programmable Logic Device, CPLD) through the enhanced serial peripheral interface (Enhanced Serial Peripheral Interface, eSPI) and the chip select signal (chipselect, CS), respectively, and the baseboard management controller can interact with the complex programmable logic device through the integrated circuit bus (Inter-Integrated Circuit, I2C), and the interaction content can be flexibly determined according to the application scenario, such as the baseboard management controller can control the temperature, voltage, etc. of the processor, and the processor or baseboard management controller can write the complex programmable logic device to control other devices in the server, etc. It should also be noted that the present application only exemplifies some devices associated with the processor and the basic input and output system, and the specific hardware architecture can be set accordingly according to the type of server, etc.
[0073] In addition, in the process of obtaining the set target quantity value, the basic input and output system can display an input window for the user. After the user enters the target quantity value in this input window, the basic input and output system obtains the target quantity value; in addition, in the process of enabling the core, the basic input and output system can write control information of whether the core is enabled into the register, and the processor then reads the control information from the register and enables or shuts down the core according to the control information; furthermore, when the basic input and output system needs to cache data, such as when it needs to cache target quantity values, first quantity values, second quantity values, etc., it can also cache through registers.
[0074] In actual applications, before adapting the target quantity value to the unit quantity information, the first quantity value, and the second quantity value, the total quantity value of the cores in all processors of the target type can also be determined; detect whether the target quantity value is greater than the total quantity value; in response to the target quantity value being greater than the total quantity value, enable the core corresponding to the total quantity value in all processors of the target type; in response to the target quantity value being less than or equal to the total quantity value, perform the step of adapting the target quantity value to the unit quantity information, the first quantity value, and the second quantity value. It should be noted that in the process of enabling the core corresponding to the total quantity value in all processors of the target type, it is equivalent to enabling all cores of all processors of the target type, and all cores of all processors of the target type can be enabled at one time through operations such as one-key setting; in addition, the core is not enabled according to the target quantity value at this time. In order to facilitate users to understand this situation, a prompt message indicating that the target quantity value is greater than the total quantity value and the core can only be enabled with the total quantity value can also be output.
[0075] From this implementation process, it can be known that the present invention takes into account that when the target quantity value is greater than the total quantity value of the cores in all processors of the target type, only the total quantity value of the cores can be enabled, and the core cannot be enabled with the target quantity value as the target. Therefore, before adapting the target quantity value with the unit quantity information, the first quantity value and the second quantity value, first detect whether the target quantity value is greater than the total quantity value. In response to the target quantity value being greater than the total quantity value, the core corresponding to the total quantity value is enabled in all processors of the target type; in response to the target quantity value being less than or equal to the total quantity value, the step of adapting the target quantity value with the unit quantity information, the first quantity value and the second quantity value is executed. In this way, it can be avoided that when the target quantity value is greater than the total quantity value, the target quantity value is still analyzed through the subsequent process of adapting the target quantity value with the unit quantity information, the first quantity value and the second quantity value, which can avoid the execution of invalid operations and improve the robustness of the solution.
[0076] In actual applications, in the process of obtaining the unit quantity information of the target type of processor-enabled cores, the unit quantity information of the target type of processor-enabled cores can be obtained, and the unit quantity information includes that the cores are enabled in groups, and the number of cores in a group of cores is the third quantity value. In other words, some processors enable cores in groups, such as SRF (Sierra Forest) processors, which enable cores in groups, so the third quantity value of a group of cores enabled by this type of processor each time needs to be used as the unit quantity information.
[0077] For specific application scenarios, please refer to Figure 3 , adapting the target quantity value to the unit quantity information, the first quantity value and the second quantity value, and enabling the corresponding cores in all processors of the target type according to the adaptation result, it can be first detected whether the target quantity value is greater than the first product value of the third quantity value and the second quantity value; in response to the target quantity value being less than or equal to the first product value, the second quantity value group of cores is enabled in all processors of the target type. At this time, the unit quantity information cores need to be enabled on each computing unit of the processor of the target type; in response to the target quantity value being greater than the first product value, the target quantity value is adapted to the unit quantity information and the first quantity value, and the corresponding cores are enabled in all processors of the target type according to the adaptation result.
[0078] From this implementation process, it can be known that the present invention takes into account that in a processor that enables cores in groups, each computing unit needs to enable at least cores of the unit quantity information, so the first product value of the third quantity value and the second quantity value can be calculated first, so as to reflect the minimum number of cores required to be enabled by the processor of the target type with the help of the first product value, and then detect whether the target quantity value is greater than the first product value of the third quantity value and the second quantity value. In response to the target quantity value being less than or equal to the first product value, the second quantity value group of cores is enabled in all processors of the target type, so as to enable the core according to the minimum number of cores required to be enabled by the processor of the target type; correspondingly, in response to the target quantity value being greater than the first product value, the target quantity value can continue to be adapted to the unit quantity information and the first quantity value, and the corresponding cores can be enabled in all processors of the target type according to the adaptation result. In this way, when the target quantity value is less than the minimum number of cores required to be enabled by the processor of the target type, the core can be enabled with the minimum number of cores required to be enabled by the processor of the target type, so as to ensure the normal operation of the processor of the target type, thereby improving the stability of the processor of the target type.
[0079] In a specific application scenario, in the process of adapting the target quantity value to the unit quantity information and the first quantity value, and enabling the corresponding cores in all processors of the target type according to the adaptation result, a second product value of the third quantity value and the first quantity value can be generated; a first remainder value of the target quantity value divided by the second product value is generated; whether the first remainder value is zero is detected; in response to the first remainder value being zero, the quotient of the target quantity value divided by the third quantity value is generated as a fourth quantity value, and the fourth quantity value group of cores is enabled in all processors of the target type. In response to the first remainder value being not zero, a prompt message that the target quantity value is invalid can be output. It should be noted that, in the case where the first remainder value is not zero, in addition to outputting a prompt message that the target quantity value is invalid, the fourth quantity value can also be fed back to the user as the number of groups of enabled cores to detect whether the user enters an instruction representing consent. If so, the fourth quantity value group of cores is enabled in all processors of the target type.
[0080] In a specific application scenario, in the process of enabling the fourth number value group of cores in all processors of the target type, the third number of cores can be enabled in each computing unit of each processor of the target type first. At this time, the number of core groups enabled is the second number value, and the difference between the fourth number value and the second number value is calculated, and the difference value is randomly selected for all unfilled computing units to obtain the selected difference computing units; then for each selected computing unit, if there is an unenabled core in the computing unit, the third number of cores in the computing unit is enabled, and the difference value is reduced by 1. If there is no unenabled core in the computing unit, the computing unit is marked as full and the difference value is kept unchanged; after the enabling operation is performed on all selected computing units, it is determined whether the difference value is zero. If so, it ends. If not, it returns to execute the difference value random selection of all unfilled computing units and subsequent operations. Of course, there may be other ways to enable the fourth number value group of cores in all processors of the target type, and the present invention is not specifically limited here.
[0081] From this implementation process, it can be seen that in the process of enabling the fourth number value group of cores in all processors of the target type, the present invention first enables the third number of cores in each computing unit of each processor of the target type, so as to ensure the minimum enabling requirement of the cores in the processor; then the difference between the fourth number value and the second number value is calculated, so as to use the difference to represent the number of cores that need to be enabled, and all the computing units that are not full are randomly selected by the difference times to obtain the selected difference computing units, so as to determine the position of the computing units where the remaining cores to be enabled are located by random selection; then for each selected computing unit, if the computing unit has an unused If there are enabled cores, the third number of cores in the computing unit are enabled, and the difference is reduced by 1. If there are no unenabled cores in the computing unit, the computing unit is marked as full, and the difference is kept unchanged to ensure that the difference can accurately reflect the number of remaining cores that need to be enabled; after the enabling operation is performed on all selected computing units, it is determined whether the difference is zero. If so, the process ends; if not, the process returns to execute the difference random selection and subsequent operations on all unfull computing units, so as to enable the remaining number of cores by reselecting computing units, and finally the number of enabled cores is accurately made to be the target number value by randomly selecting computing units.
[0082] In a specific application scenario, in the process of enabling the cores corresponding to the total quantity value in all processors of the target type, a quotient of the total quantity value divided by the third quantity value may be generated as a fifth quantity value, and the fifth quantity value group of cores may be enabled in all processors of the target type. The process of enabling the fifth quantity value group of cores in all processors of the target type may be the same as the process of enabling the fourth quantity value group of cores in all processors of the target type, and the present invention is not specifically limited here.
[0083] In actual applications, in the process of obtaining the unit quantity information of the target type of processor-enabled cores, the unit quantity information of the target type of processor-enabled cores can be obtained, and the unit quantity information includes the cores enabled in units of individual cores. In other words, some processors enable cores in units of single cores, such as the (Sierra Forest) processor, etc., which enable cores in groups, so the third quantity value of a group of cores enabled by this type of processor each time needs to be used as the unit quantity information. In other words, some processors enable cores in units of individual cores, such as the GNR (Granite Rapids) processor, etc., which enable cores in units of single cores. At this time, at least one core needs to be enabled each time a core is enabled in this type of processor.
[0084] For specific application scenarios, please refer to Figure 4, adapting the target quantity value to the unit quantity information, the first quantity value and the second quantity value, and in the process of enabling the corresponding core in all processors of the target type according to the adaptation result, it can be detected whether the target quantity value is greater than the second quantity value; in response to the target quantity value being less than or equal to the second quantity value, enabling the second quantity value of cores in all processors of the target type; in response to the target quantity value being greater than the second quantity value, adapting the target quantity value to the unit quantity information and the first quantity value, and enabling the corresponding core in all processors of the target type according to the adaptation result.
[0085] In a specific application scenario, in the process of adapting the target quantity value to the unit quantity information and the first quantity value, and enabling the corresponding core in all processors of the target type according to the adaptation result, a second remainder value of the target quantity value divided by the first quantity value can be generated; whether the second remainder value is zero is detected; in response to the second remainder value being zero, the target quantity value cores are enabled in all processors of the target type. This process is similar to the process of enabling the fourth quantity value group of cores in all processors of the target type. It is only necessary to regard the third quantity value as 1, that is, the core enabling process in the present invention can refer to the process of enabling the fourth quantity value group of cores in all processors of the target type. In response to the second remainder value not being zero, a prompt message indicating that the target quantity value is invalid is output.
[0086] In a specific application scenario, in the process of enabling cores corresponding to the total number value in all processors of the target type, the total number value of cores may be enabled in all processors of the target type.
[0087] A method for setting the number of processor cores provided by the present invention is applied to a basic input / output system, and obtains a set target number value, the target number value including the number value of cores in a processor of a target type being enabled; obtains unit number information of cores enabled in a processor of the target type; obtains a first number value of all processors of the target type; determines a second number value of computing units in all processors of the target type, the computing units being used to carry the cores; adapts the target number value to the unit number information, the first number value, and the second number value, and enables corresponding cores in all processors of the target type according to the adaptation result. The beneficial effect of the present invention is that after obtaining the target quantity value, the basic input and output system does not directly enable the target quantity value cores in all processors of the target type, but needs to adapt the target quantity value to the unit quantity information of the target type processor enabled cores, the first quantity value of all processors and the second quantity value of the computing unit, and enable the corresponding number of cores according to the adaptation result. Since the unit quantity information limits the minimum number of cores enabled each time, and the first quantity value and the second quantity value limit the minimum number of cores enabled for all processors of the target type, the present invention can determine the number value of cores that are adapted to the minimum number of cores enabled each time and the minimum number of cores enabled for all processors according to the target quantity value to enable, thereby improving the accuracy of setting the number of processor cores.
[0088] It should be noted that the method for setting the number of processor cores provided by the present invention can be flexibly set according to the application object. For example, when setting the number of CPU (Central Processing Unit) cores in a server, the server can be compatible with two types of processors or can be only provided with a single type of processor. It is only necessary to enable the corresponding core according to the method of the present invention. When the method of the present invention is applied to a basic input and output system, the whole process can be as follows:
[0089] In BIOS, create a new code DXE (Driver Exection Environment) program interface module;
[0090] In the BIOS, a new external applet interface is created to display an input window for the user, through which the user can enter the target quantity value to be set;
[0091] A program for executing the method for setting the number of processor cores of the present invention is set in the DXE code module;
[0092] The user enters the target quantity value to be set through the input window displayed by the external applet interface;
[0093] This target number value is brought into the DXE module, and the method for setting the number of processor cores of the present invention is applied to set the number of server processor cores, and the setting result is displayed through an input window;
[0094] When the server restarts and the program executes to successfully set the target number of processors, you can directly view the number of Active (enabled) Cores that have been set successfully in the human-computer interaction interface.
[0095] It should be noted that, in this process, when the core is enabled, the core can also be enabled and managed according to the bitmap that records whether the core is enabled or not, such as Figure 5 As shown, all processors and computing units can be traversed first, and the first bitmap of the computing unit can be obtained. All the obtained first bitmaps can be traversed, and available cores can be found from low to high to enable them, and the first bitmap can be updated synchronously to obtain the second bitmap; the second bitmap can be inverted to obtain the third bitmap, the third bitmap can be set to the processor, and the second bitmap can be set to the value of the core enable option in the basic input and output system.
[0096] Based on the above embodiments, the present invention provides a system for setting the number of processor cores, which is applied to a basic input and output system, including:
[0097] A first acquisition module is used to acquire a set target quantity value, where the target quantity value includes a quantity value of cores in a processor of an enabled target type;
[0098] A second acquisition module is used to obtain unit quantity information of enabled cores of a processor of a target type;
[0099] A third acquisition module, used to acquire a first quantity value of all processors of a target type;
[0100] A first determination module, configured to determine a second quantity value of computing units in all processors of a target type, the computing units being configured to carry cores;
[0101] The first setting module is used to adapt the target quantity value to the unit quantity information, the first quantity value and the second quantity value, and enable the corresponding core in all processors of the target type according to the adaptation result.
[0102] The description of a system for setting the number of processor cores provided by an embodiment of the present invention can be found in the above embodiment, which will not be repeated here.
[0103] The present invention also provides an electronic device and a computer-readable storage medium, both of which have the corresponding effects of the method for setting the number of processor cores provided in the embodiment of the present invention. Figure 6 , Figure 6 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention.
[0104] An electronic device provided by an embodiment of the present invention includes a memory 201 and a processor 202. The memory 201 stores a computer program. When the processor 202 executes the computer program, the steps of the method for setting the number of processor cores described in any of the above embodiments are implemented.
[0105] See also Figure 7 Another electronic device provided in an embodiment of the present invention may also include: an input port 203 connected to the processor 202, used to transmit commands input from the outside to the processor 202; a display unit 204 connected to the processor 202, used to display the processing results of the processor 202 to the outside; a communication module 205 connected to the processor 202, used to realize communication between the electronic device and the outside. The display unit 204 can be a display panel, a laser scanning display, etc.; the communication method adopted by the communication module 205 includes but is not limited to mobile high-definition link technology (Mobile High-Definition Link, MHL), Universal Serial Bus (Universal Serial Bus, USB), High-Definition Multimedia Interface (High-Definition Multimedia Interface, HDMI), wireless connection: wireless fidelity technology (WIreless Fidelity, WiFi), Bluetooth communication technology, low-power Bluetooth communication technology, and communication technology based on IEEE802.11s.
[0106] An embodiment of the present invention provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of the method for setting the number of processor cores described in any of the above embodiments are implemented.
[0107] The computer-readable storage medium involved in the present invention includes random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, register, hard disk, removable disk, CD-ROM (Compact Disc Read-Only Memory), or any other form of storage medium known in the technical field.
[0108] A computer program product provided by an embodiment of the present invention includes a computer program / instruction. When the computer program / instruction is executed by a processor, the following steps are implemented:
[0109] Get the set target quantity value, the target quantity value includes the quantity value of the cores in the processor of the enabled target type;
[0110] Get the unit quantity information of the processor enabled cores of the target type;
[0111] Get a first quantity value of all processors of the target type;
[0112] determining a second number value of computing units in all processors of the target type, the computing units being used to host the cores;
[0113] The target quantity value is adapted to the unit quantity information, the first quantity value, and the second quantity value, and corresponding cores are enabled in all processors of the target type according to the adaptation result.
[0114] A computer program product provided by an embodiment of the present invention includes a computer program / instruction, which implements the following steps when executed by a processor: before adapting the target quantity value to the unit quantity information, the first quantity value and the second quantity value, determining the total quantity value of cores in all processors of the target type; detecting whether the target quantity value is greater than the total quantity value; in response to the target quantity value being greater than the total quantity value, enabling the core corresponding to the total quantity value in all processors of the target type; in response to the target quantity value being less than or equal to the total quantity value, executing the step of adapting the target quantity value to the unit quantity information, the first quantity value and the second quantity value.
[0115] A computer program product provided by an embodiment of the present invention includes a computer program / instruction, which implements the following steps when executed by a processor: obtaining unit quantity information of enabled cores of a processor of a target type, the unit quantity information including enabling cores in groups, and the number of cores in a group of cores being a third quantity value.
[0116] A computer program product provided by an embodiment of the present invention includes a computer program / instruction, which implements the following steps when executed by a processor: detecting whether a target quantity value is less than a first product value of a third quantity value and a second quantity value; in response to the target quantity value being less than the first product value, enabling a group of cores of the second quantity value in all processors of the target type; in response to the target quantity value being greater than or equal to the first product value, adapting the target quantity value to unit quantity information and the first quantity value, and enabling the corresponding core in all processors of the target type according to the adaptation result.
[0117] A computer program product provided by an embodiment of the present invention includes a computer program / instruction, which implements the following steps when executed by a processor: generating a second product value of a third quantity value and a first quantity value; generating a first remainder value of a target quantity value divided by the second product value; detecting whether the first remainder value is zero; in response to the first remainder value being zero, generating a quotient value of the target quantity value divided by the third quantity value as a fourth quantity value, and enabling the fourth quantity value group cores in all processors of the target type.
[0118] A computer program product provided by an embodiment of the present invention includes a computer program / instruction, which implements the following steps when executed by a processor: after detecting whether a first remainder value is zero, in response to the first remainder value being not zero, outputting a prompt message that the target quantity value is invalid.
[0119] A computer program product provided by an embodiment of the present invention includes a computer program / instruction, which implements the following steps when executed by a processor: generating a quotient of a total quantity value divided by a third quantity value as a fifth quantity value, and enabling cores of a fifth quantity value group in all processors of the target type.
[0120] A computer program product provided by an embodiment of the present invention includes a computer program / instruction, which implements the following steps when executed by a processor: obtaining unit quantity information of enabled cores of a processor of a target type, wherein the unit quantity information includes enabling cores in units of individual cores.
[0121] A computer program product provided by an embodiment of the present invention includes a computer program / instruction, which implements the following steps when executed by a processor: detecting whether a target quantity value is less than a second quantity value; in response to the target quantity value being less than the second quantity value, enabling the second quantity value of cores in all processors of the target type; in response to the target quantity value being greater than or equal to the second quantity value, adapting the target quantity value to the unit quantity information and the first quantity value, and enabling the corresponding cores in all processors of the target type according to the adaptation result.
[0122] A computer program product provided by an embodiment of the present invention includes a computer program / instruction, which implements the following steps when executed by a processor: generating a second remainder value when a target quantity value is divided by a first quantity value; detecting whether the second remainder value is zero; and in response to the second remainder value being zero, enabling a target number of cores in all processors of the target type.
[0123] A computer program product provided by an embodiment of the present invention includes a computer program / instruction, which implements the following steps when executed by a processor: after detecting whether the second remainder value is zero, in response to the second remainder value being not zero, outputting a prompt message that the target quantity value is invalid.
[0124] A computer program product provided by an embodiment of the present invention includes a computer program / instruction. When the computer program / instruction is executed by a processor, the following steps are implemented: enabling a total number of cores in all processors of a target type.
[0125] For the description of the relevant parts of a processor core number setting system, electronic device, computer-readable storage medium, and computer program product provided by an embodiment of the present invention, please refer to the detailed description of the corresponding parts in a processor core number setting method provided by an embodiment of the present invention, which will not be repeated here. In addition, the parts of the above technical solutions provided by the embodiments of the present invention that are consistent with the implementation principles of the corresponding technical solutions in the prior art are not described in detail to avoid excessive elaboration.
[0126] It should also be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0127] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for setting the number of processor cores, characterized in that: Applicable to basic input and output systems, including: Obtaining a set target quantity value, the target quantity value comprising a quantity value of cores in a processor of an enabled target type; Obtaining unit quantity information of processor-enabled cores of the target type; Obtain a first quantity value of all processors of the target type; determining a second number value of computing units in all processors of the target type, the computing units being used to host the cores; Determining a total number of cores in all processors of the target type; Detecting whether the target quantity value is greater than the total quantity value; In response to the target quantity value being greater than the total quantity value, enabling cores corresponding to the total quantity value in all processors of the target type; In response to the target quantity value being less than or equal to the total quantity value, the target quantity value is adapted to the unit quantity information, the first quantity value, and the second quantity value, and corresponding cores are enabled in all processors of the target type according to the adaptation result.
2. The method for setting the number of processor cores according to claim 1, characterized in that: Obtaining unit quantity information of the processor enabled cores of the target type, including: Unit quantity information of enabled cores of the processor of the target type is obtained, where the unit quantity information includes that cores are enabled in groups, and the number of cores in a group of cores is a third quantity value.
3. The method for setting the number of processor cores according to claim 2, characterized in that: Adapting the target quantity value to the unit quantity information, the first quantity value, and the second quantity value, and enabling corresponding cores in all processors of the target type according to the adaptation result, includes: Detecting whether the target quantity value is greater than a first product value of the third quantity value and the second quantity value; In response to the target quantity value being less than or equal to the first product value, enabling the second quantity value group of cores in all processors of the target type; In response to the target quantity value being greater than the first product value, the target quantity value is adapted to the unit quantity information and the first quantity value, and corresponding cores are enabled in all processors of the target type according to the adaptation result.
4. The method for setting the number of processor cores according to claim 3, characterized in that: Adapting the target quantity value to the unit quantity information and the first quantity value, and enabling corresponding cores in all processors of the target type according to the adaptation result, includes: generating a second product value of the third quantity value and the first quantity value; generating a first remainder value by dividing the target quantity value by the second product value; detecting whether the first remainder value is zero; In response to the first remainder value being zero, a quotient of the target quantity value divided by the third quantity value is generated as a fourth quantity value, and the fourth quantity value group of cores is enabled in all processors of the target type.
5. The method for setting the number of processor cores according to claim 4, characterized in that: After detecting whether the first remainder value is zero, the method further includes: In response to the first remainder value being not zero, a prompt message indicating that the target quantity value is invalid is outputted.
6. The method for setting the number of processor cores according to claim 2, characterized in that: Enabling cores corresponding to the total number value in all processors of the target type includes: A quotient of the total quantity value divided by the third quantity value is generated as a fifth quantity value, and the fifth quantity value group of cores is enabled in all processors of the target type.
7. The method for setting the number of processor cores according to claim 1, characterized in that: Obtaining unit quantity information of the processor enabled cores of the target type, including: The unit quantity information of the enabled cores of the processor of the target type is obtained, where the unit quantity information includes the cores enabled in units.
8. The method for setting the number of processor cores according to claim 7, characterized in that: Adapting the target quantity value to the unit quantity information, the first quantity value, and the second quantity value, and enabling corresponding cores in all processors of the target type according to the adaptation result, includes: Detecting whether the target quantity value is less than the second quantity value; In response to the target quantity value being less than or equal to the second quantity value, enabling the second quantity value of cores in all processors of the target type; In response to the target quantity value being greater than the second quantity value, the target quantity value is adapted to the unit quantity information and the first quantity value, and corresponding cores are enabled in all processors of the target type according to the adaptation result.
9. The method for setting the number of processor cores according to claim 8, characterized in that: Adapting the target quantity value to the unit quantity information and the first quantity value, and enabling corresponding cores in all processors of the target type according to the adaptation result, includes: generating a second remainder value by dividing the target quantity value by the first quantity value; detecting whether the second remainder value is zero; In response to the second remainder value being zero, enabling the target number of cores in all processors of the target type.
10. The method for setting the number of processor cores according to claim 9, characterized in that: After detecting whether the second remainder value is zero, the method further includes: In response to the second remainder value being not zero, a prompt message indicating that the target quantity value is invalid is output.
11. The method for setting the number of processor cores according to claim 7, characterized in that: Enabling cores corresponding to the total number value in all processors of the target type includes: The total number of cores is enabled in all processors of the target type.
12. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instruction is executed by a processor, the steps of the method for setting the number of processor cores described in any one of claims 1 to 11 are implemented.
13. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, used to implement the steps of the method for setting the number of processor cores as described in any one of claims 1 to 11 when executing the computer program.
14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method for setting the number of processor cores according to any one of claims 1 to 11 are implemented.
