GPU equipment registration method and device, equipment and medium
By pre-deploying common attribute nodes and default functions, and dynamically replacing inconsistent states and functions, the code redundancy and poor compatibility issues of GPU device registration in the hwmon subsystem are resolved, achieving efficient and maintainable GPU device registration.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- NINGCHANG INFORMATION TECH (HANGZHOU) CO LTD
- Filing Date
- 2025-12-29
- Publication Date
- 2026-04-21
AI Technical Summary
In existing technologies, the hwmon subsystem of the Linux system requires the development of independent device driver registration code for each GPU device, resulting in code redundancy, poor compatibility, and difficulty in maintenance and expansion.
By pre-deploying common attribute nodes and default functions, determining the model based on the manufacturer ID and GPU device ID, and dynamically replacing inconsistent states and functions, the registration of GPU devices in the hwmon subsystem is achieved.
It avoids the need to repeatedly write basic code, improves code reusability and maintainability, simplifies the registration process, and ensures compatibility and efficiency.
Smart Images

Figure CN121900807A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of server monitoring technology, and in particular to a method, apparatus, device and medium for registering GPU devices. Background Technology
[0002] In modern server monitoring systems, the Baseboard Management Controller (BMC) is a core component responsible for monitoring and managing the server's hardware status, such as temperature, speed, and bandwidth. It provides the server with hardware status information to ensure stable and efficient long-term operation. On servers running Graphics Processing Units (GPUs), the BMC needs to monitor the status information of multiple GPUs in real time. The current design uses a Linux system to configure the BMC to monitor the status information of multiple GPUs and report it to the user.
[0003] However, there are many GPU device manufacturers at home and abroad. In R&D projects, there may be scenarios where different manufacturers' GPU devices are matched with different server monitoring systems according to customer needs. In the existing technology, the hwmon subsystem of the Linux system requires the development of independent device driver registration code for each GPU device. As a result, there is a lot of duplicate code in data structure and interface logic between different GPU device drivers in the same hwmon subsystem, which causes code redundancy, poor system compatibility, and makes subsequent maintenance and function expansion difficult. Summary of the Invention
[0004] This application provides a method, apparatus, device, and medium for registering GPU devices, in order to solve the problem of code redundancy when registering different GPU devices in the same hwmon subsystem.
[0005] In a first aspect, this application provides a method for registering a GPU device, the method comprising:
[0006] Receive a registration request from a GPU device, wherein the registration request carries the manufacturer ID and GPU device ID of the GPU device;
[0007] Invoke the default state of whether the pre-deployed general attribute nodes are exposed and the default function of each preset, and write the default state of whether the general attribute nodes are exposed and the default function of each preset into the registration function;
[0008] Based on the manufacturer ID and the GPU device ID, determine the model of the GPU device; determine the actual state of the attribute nodes corresponding to the GPU device model and the actual functions used;
[0009] If the actual state of the attribute node corresponding to the GPU device of the specified model is inconsistent with the default state, or any of the actual functions used are inconsistent with the corresponding default functions, then the actual state or the actual function used is used to replace the inconsistent default state or default function in the registration function for modification, and the GPU device of the specified model is registered to the hwmon subsystem based on the modified registration function.
[0010] By pre-deploying the default states of whether common attribute nodes are exposed, applicable to most GPU devices, and the preset default functions for each, during GPU device registration, it is only necessary to replace the default states of whether common attribute nodes are exposed or the preset default functions with the actual states and functions of each attribute of the GPU device itself that are inconsistent. This greatly avoids the repetitive writing of basic code, and realizes that the common logic code only needs to be written once. When adding a new GPU device model, it is only necessary to expand the model lookup table and the corresponding actual configuration, without rewriting the entire driver registration process. This solves the problem of code redundancy and poor compatibility caused by writing independent driver registration code for each GPU device in the existing technology, and greatly improves the reusability and maintainability of the code.
[0011] In one possible implementation, the method further includes:
[0012] If the actual state of the attribute node corresponding to the GPU device of the specified model is consistent with the default state, and each of the actual functions used is consistent with the corresponding default function, then the GPU device of the specified model is registered to the hwmon subsystem based on the registration function.
[0013] By using the above method, GPU devices that conform to general standards can be registered directly based on pre-deployed information, avoiding unnecessary configuration queries and replacement operations, simplifying the logic, and improving the execution efficiency of GPU device registration, thereby further demonstrating the advantages of the general GPU abstraction layer design of this application.
[0014] In one possible implementation, after writing the default state of whether the general attribute node is exposed and each preset default function into the registration function, and before determining the model of the GPU device based on the manufacturer ID and the GPU device ID, the method further includes:
[0015] The GPU device is registered to the hwmon subsystem based on the registration function;
[0016] Registering the GPU device of the aforementioned model to the hwmon subsystem based on the modified registration function includes:
[0017] The modified registration function re-registers the GPU device of the aforementioned model into the hwmon subsystem.
[0018] The above method enables instant registration of GPU devices, allowing users to begin basic monitoring of the GPU device without waiting for a complex judgment process. Subsequently, after completing accurate model identification and configuration adaptation, it seamlessly replaces the configuration with accurate settings, eliminating the problem of monitoring startup delay or monitoring service lag caused by the time-consuming judgment process in traditional methods. This application ensures both final compatibility and accuracy, and achieves a balance between efficiency and precision. It is particularly suitable for server BMC management scenarios with strict requirements for system startup time and service availability.
[0019] In one possible implementation, determining the GPU device model corresponding to each actual function in use includes:
[0020] Based on the preset protocol mapping table and the model of the GPU device, determine the actual communication protocol used by the GPU device of the specified model to perform hardware monitoring data communication with the hwmon subsystem;
[0021] Based on a preset function set mapping table and the actual communication protocol, a corresponding function set is determined; wherein the functions in the function set are each actual function used by the GPU device of the specified model.
[0022] By using the communication protocol as the basis for function selection, the accuracy of the read functions, write functions, and node permission setting functions equipped on the GPU device is ensured. The source and selection criteria of the actual functions used are clarified, avoiding the problem of incompatibility due to inconsistent hardware access methods. This enables the driver to have the adaptive capability of the hardware access layer, significantly enhancing the robustness and broad compatibility of the solution.
[0023] In one possible implementation, the default functions include read functions, write functions, and node permission setting functions.
[0024] By setting the read function, write function, and node permission setting function as default functions in the above manner, the general logic code only needs to be written once, avoiding code redundancy caused by writing separate driver registration code for GPU devices.
[0025] Secondly, this application provides an apparatus for registering a GPU device, the apparatus comprising:
[0026] The receiving module is configured to receive a registration request from a GPU device, wherein the registration request carries the manufacturer ID and GPU device ID of the GPU device;
[0027] The processing module is used to call the default state of whether the pre-deployed general attribute nodes are exposed and each preset default function, and write the default state of whether the general attribute nodes are exposed and each preset default function into the registration function; determine the model of the GPU device according to the manufacturer ID and the GPU device ID; determine the actual state of whether the attribute nodes corresponding to the model of the GPU device are exposed and each actual function used; if the actual state of the attribute node corresponding to the model of the GPU device is inconsistent with the default state, or any of the actual functions used is inconsistent with the corresponding default function, then the actual state or the actual function used replaces the corresponding inconsistent default state or default function in the registration function for modification, and registers the model of the GPU device to the hwmon subsystem based on the modified registration function.
[0028] In one possible implementation, the processing module is further configured to register the GPU device of the specified model to the hwmon subsystem based on the registration function if the actual state of the attribute node corresponding to the GPU device of the specified model is consistent with the default state, and each of the actual used functions is consistent with the corresponding default function.
[0029] In one possible implementation, the processing module is further configured to register the GPU device to the hwmon subsystem based on the registration function;
[0030] The processing module is specifically used for:
[0031] The modified registration function re-registers the GPU device of the aforementioned model into the hwmon subsystem.
[0032] In one possible implementation, the processing module is specifically used for:
[0033] Based on a preset protocol mapping table and the model of the GPU device, the actual communication protocol used by the GPU device of the specified model for hardware monitoring data communication with the hwmon subsystem is determined; based on a preset function set mapping table and the actual communication protocol, the corresponding function set is determined; wherein the functions in the function set are each actual function used by the GPU device of the specified model.
[0034] In one possible implementation, the default function includes a read function, a write function, and a permission setting function.
[0035] Thirdly, this application also provides an electronic device, which includes at least a processor and a memory, wherein the processor is configured to execute a computer program stored in the memory to implement the steps of the GPU device registration method as described in any of the first aspects.
[0036] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program, the computer program including program instructions, which, when executed by a computer, cause the computer to perform the steps of the GPU device registration method as described in any one of the first aspects.
[0037] Fifthly, embodiments of this application provide a computer program product comprising: computer program code, which, when executed on a computer, causes the computer to perform the steps of the GPU device registration method as described in any one of the first aspects. Attached Figure Description
[0038] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0039] Figure 1 A simplified diagram illustrating traditional GPU device driver registration;
[0040] Figure 2 This is a schematic diagram illustrating a method for registering a GPU device according to an embodiment of this application.
[0041] Figure 3 A simplified schematic diagram illustrating GPU device driver registration provided in this application;
[0042] Figure 4 This is an overall schematic diagram of a GPU device registration method provided in an embodiment of this application;
[0043] Figure 5 This application provides a schematic diagram illustrating the process of BMC accessing attribute nodes after GPU device registration is completed.
[0044] Figure 6 A simplified process diagram illustrating a method for registering a GPU device provided in an embodiment of this application;
[0045] Figure 6a A simplified structural diagram of the pre-deployment of an hwmon subsystem provided in an embodiment of this application;
[0046] Figure 6b A schematic diagram illustrating the main contents of the general GPU general layer provided in the embodiments of this application;
[0047] Figure 6c A schematic diagram illustrating possible differences in the embodiments of this application;
[0048] Figure 7 A schematic diagram of a device structure for GPU device registration provided in an embodiment of this application;
[0049] Figure 8 This is a schematic diagram of an electronic device structure provided in an embodiment of this application. Detailed Implementation
[0050] To make the objectives and implementation methods of this application clearer, the exemplary implementation methods of this application will be clearly and completely described below with reference to the accompanying drawings of the exemplary embodiments of this application. Obviously, the exemplary embodiments described are only some embodiments of this application, and not all embodiments.
[0051] It should be noted that the brief descriptions of terms in this application are only for the convenience of understanding the embodiments described below, and are not intended to limit the embodiments of this application. Unless otherwise stated, these terms should be understood in their ordinary and common meaning.
[0052] The terms "first," "second," "third," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar or related objects or entities, and do not necessarily imply a specific order or sequence, unless otherwise specified. It should be understood that such terms are interchangeable where appropriate.
[0053] The terms “comprising” and “having”, and any variations thereof, are intended to cover but not exclude inclusion, for example, a product or device that includes a range of components is not necessarily limited to all of the components that are clearly listed, but may include other components that are not clearly listed or that are inherent to such product or device.
[0054] The term "module" refers to any known or subsequently developed hardware, software, firmware, artificial intelligence, fuzzy logic, or combination of hardware and / or software code that is capable of performing the functions associated with that element.
[0055] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
[0056] For ease of explanation, the above description has been provided in conjunction with specific embodiments. However, the above exemplary discussion is not intended to be exhaustive or to limit the embodiments to the specific forms disclosed above. Various modifications and variations can be obtained based on the above teachings. The selection and description of the above embodiments are for the purpose of better explaining the principles and practical applications, thereby enabling those skilled in the art to better utilize the described embodiments and various different variations of embodiments suitable for specific use considerations.
[0057] The following explanations of some terms used in the embodiments of this application are provided to facilitate understanding by those skilled in the art.
[0058] (1) hwmon subsystem: This refers to a subsystem in the Linux kernel that provides support for hardware monitoring, such as monitoring hardware temperature, voltage, fan speed, etc. Specifically, when a hardware monitoring device, such as a GPU device, is registered to the hwmon subsystem by a driver, the hwmon subsystem will automatically create a file node for the corresponding hardware monitoring device in a specific directory and create the corresponding attribute file.
[0059] (2) Baseboard Management Controller (BMC): A dedicated controller used for monitoring and managing servers.
[0060] (3) Kernel: The core of the operating system.
[0061] To facilitate understanding, the technical background of the embodiments of this application will be described in detail first.
[0062] Current GPU device monitoring relies on the Base Computing Controller (BMC) to poll and access the hwmon file node to obtain GPU device information. The hwmon file node is created by the BMC during GPU device driver registration. However, existing GPU device driver registration processes are independent and unrelated. The Linux system's hwmon subsystem requires developing separate device registration code for each GPU device, resulting in redundancy of GPU device driver registration code within the same hwmon subsystem. This leads to wasted manpower and resources in subsequent GPU device monitoring due to duplicate code development.
[0063] Figure 1 A simplified diagram illustrating traditional GPU device driver registration, such as... Figure 1 As shown, the Linux hwmon subsystem serves as the core framework for hardware monitoring. It provides an accessible file operation interface for each GPU device through a unified interface standard, and performs corresponding driver registration for each GPU device, such as GPU devices from manufacturer A and GPU devices from manufacturer B. This enables centralized management of key hardware parameters such as temperature, voltage, and fan speed for each GPU device.
[0064] In view of this, this application provides a method, apparatus, device, and medium for GPU device registration. In this method, by pre-deploying the default state of whether a common attribute node is exposed, applicable to most GPU devices, and each preset default function, when registering a GPU device, it is only necessary to replace the default state of whether the common attribute node is exposed or the preset default function with the corresponding replacement where the actual state and actual function of each attribute of the GPU device are inconsistent. This greatly avoids the repetitive writing of basic code, and realizes that the common logic code only needs to be written once. When adding a new GPU device model, it is only necessary to expand the model lookup table and the corresponding actual configuration, without rewriting the entire driver registration process. This solves the problem of code redundancy and poor compatibility caused by writing independent driver registration code for each GPU device in the prior art, and greatly improves the reusability and maintainability of the code.
[0065] Example 1:
[0066] Figure 2 This application provides a schematic diagram of a method for registering a GPU device, which includes the following steps:
[0067] S201: Receive a registration request for a GPU device, wherein the registration request carries the manufacturer ID and GPU device ID of the GPU device.
[0068] The GPU device registration method provided in this application embodiment is applied to BMC.
[0069] Registration request: This refers to the request to register the GPU device with the hwmon subsystem of the Linux system.
[0070] Vendor ID: A unique numerical identifier, typically assigned by standardization organizations such as PCI-SIG, used to identify the manufacturer of hardware devices. For example, 0x10DE represents manufacturer A, and 0x1002 represents manufacturer B.
[0071] GPU Device ID: This is a unique numerical identifier used in conjunction with the manufacturer ID to uniquely identify a specific GPU product model from a particular manufacturer. For example, the NVIDIA GeForce RTX 4090 corresponds to a specific device ID.
[0072] The BMC receives registration requests from GPU devices, which include the manufacturer ID and GPU device ID of the GPU device to be registered. These two IDs together form the "fingerprint" of the device model, serving as the key basis for subsequent GPU device model identification and configuration lookup. This registration request can be pushed by the Basic Input / Output System (BIOS) or detected in the device's Peripheral Component Interconnect (PCI) configuration space or other standard hardware interfaces and sent to the BMC.
[0073] S202: Invoke the default state of whether the pre-deployed general attribute nodes are exposed and the default function of each preset, and write the default state of whether the general attribute nodes are exposed and the default function of each preset into the registration function.
[0074] Pre-deployment refers to a set of general configurations predefined during the compilation of driver code. In this application, it refers to pre-deployed general attribute nodes and default functions.
[0075] The process for determining the default state of pre-deployed general attribute nodes is as follows: Device information for multiple basic or general GPU devices is collected beforehand. Based on this information, each attribute of each GPU device and its corresponding exposed state are determined. The frequency of occurrence of the same attribute is then determined, and attributes with frequencies exceeding a preset threshold are selected as general attributes. For each selected general attribute, the frequency of occurrence of the same state is determined, and the state with the highest frequency is selected as the default state for that general attribute, thus obtaining the default state of pre-deployed general attribute nodes. The attributes of the GPU devices include, but are not limited to, temperature, voltage, and power. The default exposed state refers to defining a default visible or hidden state for each pre-deployed general attribute node. For example, temperature and voltage nodes are set to the exposed state (visible state) by default, while power consumption nodes are set to the non-exposed state (hidden state).
[0076] The process for determining each pre-deployed default function is as follows: device information of multiple basic or general GPU devices is collected in advance, and based on the collected device information of multiple GPU devices, the read function, write function, and node permission setting function of each GPU device are determined; then, for functions of the same type, such as read functions, the number of times the same function content is corresponding to the function of that type is determined, and the function content corresponding to the maximum number of times is selected as the default function of that type.
[0077] The defined general attributes, the default state corresponding to each general attribute, and the default function are stored in the general GPU abstraction layer in the hwmon subsystem. The general GPU abstraction layer can also be called the general GPU abstraction device, which standardizes the GPU device interface and access operations. In other words, in the hwmon subsystem, a set of general attribute nodes and a set of preset default functions are defined for the GPU device abstraction.
[0078] In one possible implementation, a GPU device designed by a commonly used manufacturer (A) can be directly designated as a general benchmark. Then, the temperature, power consumption, bandwidth, and transmission rate of this benchmark GPU device are used as general attributes of the GPU device. The exposure status of each general attribute is determined, and this exposure status is set as the default status. Furthermore, the read functions, write functions, and node permission setting functions corresponding to manufacturer A's GPU device are used as the default functions for the GPU device. All general attributes, their default statuses, and default functions are stored in the general GPU abstraction layer of the hwmon subsystem.
[0079] When a registration request is received, since the specific device model is unknown, BMC first calls the default state of whether the pre-deployed general attribute nodes are exposed and the default function of each preset, and writes the default state of whether the general attribute nodes are exposed and the default function of each preset into the registration function. That is, it constructs a basic hwmon registration information structure based on general assumptions. This is a "template" or "draft", and the default state of whether the general attribute nodes are exposed and the default function contained therein are preset and general.
[0080] This application pre-deploys a baseline configuration template representing a general GPU abstraction layer, which assumes the monitoring characteristics that an ideal or most general GPU device should possess. Upon receiving a GPU device registration request, this baseline configuration template is first invoked to create a temporary information structure. This information structure is used by the Linux kernel's hwmon subsystem to complete GPU device registration; this information structure is the registration function in the current context. Subsequently, the default states of whether the aforementioned general attribute nodes are exposed and each preset default function are written into the corresponding fields of this temporary information structure, forming the initial "registration function" content.
[0081] S203: Determine the model of the GPU device based on the manufacturer ID and the GPU device ID; determine the actual state of the attribute node corresponding to the model of the GPU device and the actual function used.
[0082] Actual state: The actual state required for a specific attribute node for a particular GPU model, as opposed to the default state.
[0083] Actual usage functions: Functions that are actually required for a specific type of GPU device.
[0084] BMC internally stores a lookup table that records the equipment manuals provided by the manufacturers. This table uses the manufacturer ID and GPU device ID as keys to map to the specific GPU device model string. By querying this table, the device model can be accurately determined from the manufacturer ID and GPU device ID.
[0085] Using the received manufacturer ID and GPU device ID, BMC queries its internally stored lookup table to determine the specific model of the GPU device, such as "NVIDIA A100" or "Tianshu BI-V100". Then, based on this model, it retrieves the actual configuration information for that GPU model from a pre-built configuration library, including:
[0086] (1) Actual status of attribute nodes being exposed: The actual attribute node exposure requirements for this model of GPU device. For example, a certain model of GPU device may not support power consumption monitoring, so the actual status of the attribute node corresponding to power consumption is "not exposed".
[0087] (2) Each actual function used: The actual function used by the GPU device of this model. For example, the actual read function of the GPU device of this model is vendor_specific_read, rather than the default general read function.
[0088] S204: If the actual state of the attribute node corresponding to the GPU device of the specified model is inconsistent with the default state, or any of the actual functions used are inconsistent with the corresponding default functions, then the actual state or the actual function used is used to replace the inconsistent default state or default function in the registration function for modification, and the GPU device of the specified model is registered to the hwmon subsystem based on the modified registration function.
[0089] The actual state obtained in S203 is compared item by item with the default state in S202, and the actual function used is compared with the default function. If any inconsistency is found, for example, the default is to expose power nodes, but the actual state requires them to be hidden; or the default general read function is different from the actual read function used for this model, then the corresponding inconsistency in the registration function is replaced with the actual state or the actual function used, thereby dynamically "modifying" the configuration to be used for registration.
[0090] Finally, based on the adapted information structure, namely the "modified registration function," the GPU device is registered to the hwmon subsystem. After successful registration, hwmon will create a file node in the / sys / class / hwmon / hwmonX / directory that precisely matches the attributes of the GPU device.
[0091] In this embodiment, by pre-deploying the default state of whether a common attribute node is exposed, applicable to most GPU devices, and each preset default function, when registering a GPU device, it is only necessary to replace the default state of whether the common attribute node is exposed or the preset default function with the corresponding replacement where the actual state and actual function of each attribute of the GPU device are inconsistent. This greatly avoids the repetitive writing of basic code, and realizes that the common logic code only needs to be written once. When adding a new GPU device model, it is only necessary to expand the model lookup table and the corresponding actual configuration, without rewriting the entire driver registration process. This solves the problem of code redundancy and poor compatibility caused by writing independent driver registration code for each GPU device in the prior art, and greatly improves the reusability and maintainability of the code.
[0092] Figure 3 A simplified schematic diagram of GPU device driver registration provided in this application is shown below. Figure 3 As shown, the hwmon subsystem serves as the core framework for hardware monitoring. A general-purpose GPU abstract device is pre-deployed in the hwmon subsystem. First, the default state (gpu_common) and default function corresponding to each general attribute are called. Then, the actual state (gpu_vendor) and actual usage function of the corresponding attribute of the GPU device to be registered are determined, thereby completing the subsequent registration of the GPU device.
[0093] Example 2:
[0094] To facilitate the registration of GPU devices, this application supplements the simplified process of Embodiment 1 described above when the GPU device fully conforms to general benchmarks. Specifically:
[0095] If the actual state of the attribute node corresponding to the GPU device of the specified model is consistent with the default state, and each of the actual functions used is consistent with the corresponding default function, then the GPU device of the specified model is registered to the hwmon subsystem based on the registration function.
[0096] In S204, during dynamic comparison, a situation may occur where, for some very standard GPU devices, the actual state of the attribute node corresponding to that GPU model is consistent with the default state, and each actual function used is consistent with the corresponding default function. This indicates that the GPU model fully complies with the baseline specification defined by the general GPU abstraction layer and requires no customized adaptation.
[0097] In this case, BMC will directly use the registration function, which contains the default state and default functions in S202, to complete the registration of the GPU device.
[0098] In this application embodiment, GPU devices that conform to general standards are directly registered based on pre-deployed information, avoiding unnecessary configuration query and replacement operations, simplifying the logic, and improving the execution efficiency of GPU device registration, thereby further demonstrating the advantages of the general GPU abstraction layer design of this application.
[0099] Example 3:
[0100] To improve the efficiency of GPU device registration, after writing the default state of whether the general attribute node is exposed and each preset default function into the registration function, and before determining the model of the GPU device based on the manufacturer ID and the GPU device ID, the method further includes:
[0101] The GPU device is registered to the hwmon subsystem based on the registration function;
[0102] Registering the GPU device of the aforementioned model to the hwmon subsystem based on the modified registration function includes:
[0103] The modified registration function re-registers the GPU device of the aforementioned model into the hwmon subsystem.
[0104] After obtaining the registration function in S202, BMC does not wait for subsequent comparisons and immediately registers the GPU device to the hwmon subsystem based on this registration function, i.e., it performs initial registration of the GPU device. After the initial registration is completed, S203 is executed to determine the GPU device model based on the manufacturer ID and GPU device ID, and to determine whether the attribute nodes corresponding to this model of GPU device are exposed in their actual state and each actual function used. Then, S204 is executed for comparison and judgment. If there are inconsistencies, the corresponding inconsistent content in the registration function is replaced to obtain a modified registration function. Based on the modified registration function, the GPU device of this model is re-registered to the hwmon subsystem.
[0105] In this embodiment, upon receiving a registration request from a GPU device, the BMC writes the default state of whether the general attribute nodes are exposed and each preset default function into the registration function. Based on this registration function, the GPU device is directly registered to the hwmon subsystem, achieving instant registration of the GPU device. Users can begin basic monitoring of the GPU device without waiting for a complex judgment process. Subsequently, after completing accurate model identification and configuration adaptation, it seamlessly replaces the accurate configuration, eliminating the problem of monitoring startup delay or monitoring service lag caused by the time-consuming judgment in the traditional method. This application ensures both final compatibility and accuracy, and achieves a balance between efficiency and precision. It is particularly suitable for server BMC management scenarios with strict requirements for system startup time and service availability.
[0106] Example 4:
[0107] To accurately register GPU devices to the hwmon subsystem, this application also provides detailed specifications for the process of determining the corresponding actual usage function for each GPU device, specifically: determining the corresponding actual usage function for the GPU device of the specified model includes:
[0108] Based on the preset protocol mapping table and the model of the GPU device, determine the actual communication protocol used by the GPU device of the specified model to perform hardware monitoring data communication with the hwmon subsystem;
[0109] Based on a preset function set mapping table and the actual communication protocol, a corresponding function set is determined; wherein the functions in the function set are each actual function used by the GPU device of the specified model.
[0110] Based on the GPU device model identified in S203, BMC determines the actual communication protocol used for hardware monitoring data communication between the GPU device and the hwmon subsystem by querying a preset protocol mapping table. This communication protocol may be a standard I... 2 C, I 3C could also be a manufacturer-defined proprietary protocol. The default protocol mapping table records the actual communication protocol used by each GPU model for hardware monitoring data communication with the hwmon subsystem. For example, the actual communication protocol used by the Tianshu BI-V100 is I... 2 C. The actual communication protocol used by the BI-V150 is I. 3 C.
[0111] The BMC also stores pre-defined function sets and function set mapping tables. These function sets are pre-written and compiled based on the hardware interface specification documents provided by each GPU device manufacturer, i.e., the device manual for that GPU device. A particular function set includes each actually used function corresponding to the actual communication protocol of a specific GPU model, such as read functions, write functions, and node permission setting functions. The function set mapping table records the function set corresponding to each communication protocol; for example, communication protocol M corresponds to function set m, and communication protocol N corresponds to function set n.
[0112] Based on the determined actual communication protocol, BMC precisely selects a set of functions from a preset function set that matches the actual communication protocol, and uses these functions as the actual functions used by the current GPU model. For example, if the actual communication protocol is I... 2 C, then select the corresponding function set including i 2 c_read_temp、i 2 Functions such as c_write_fan; if it is a vendor's proprietary protocol, then select the corresponding function set including functions such as vendor_x_protocol_read.
[0113] In this embodiment, by using the communication protocol as the basis for function selection, the accuracy of the read functions, write functions, and node permission setting functions equipped on the GPU device is ensured. The source and selection basis of the actual functions used are clarified, avoiding the problem of incompatibility due to inconsistent hardware access methods. This enables the driver to have the adaptive capability of the hardware access layer, significantly enhancing the robustness and broad compatibility of the solution.
[0114] Example 5:
[0115] This embodiment defines the specific types of default functions and actually used functions in the above embodiments, clarifying the core operation interfaces that the driver needs to implement. Specifically, the default functions include read functions, write functions, and node permission setting functions.
[0116] In this application, the functions involved mainly fall into the following two categories, which together constitute the set of operations required by the hwmon subsystem for registering GPU device drivers:
[0117] (1) Read and write functions: These are the core functions of the hwmon subsystem for interacting with GPU devices. They are used by the BMC to perform operations on the GPU devices and return the results. For example, the read function is used to read specific sensor registers.
[0118] (2) Node permission setting function: This function is used to set the access permissions for each created attribute node, such as whether it is read-only, whether it is writable by the root user with the highest privileges, and whether it is visible. By using the node permission setting function, attribute nodes that are exposed by default in the general GPU device abstraction layer but are not supported or desired by this model can be "hidden" or their read and write permissions can be modified, thereby achieving fine-grained management of attribute nodes.
[0119] In this embodiment, the read function, write function, and node permission setting function are set as default functions, which means that the general logic code only needs to be written once, avoiding code redundancy caused by writing independent driver registration code for GPU devices.
[0120] Example 6:
[0121] For ease of understanding, this application provides an overall description of the method for GPU device registration. Figure 4 This is an overall schematic diagram of a method for registering a GPU device provided in an embodiment of this application. The process includes the following steps:
[0122] S401: Collects GPU device information from mainstream manufacturers, using the most widely used and well-known manufacturers as a benchmark. It identifies common GPU device attributes such as temperature, power consumption, bandwidth, and transmission rate, and determines whether each attribute is exposed or not, setting the corresponding exposure status as the default status. It also sets the read function, write function, and node permission setting function of the GPU device as the default functions of the GPU device. The common attributes of the GPU device, the exposure status of each common attribute, and the default functions are abstracted into a GPU device attribute set in the Linux hwmon subsystem, serving as the basis for subsequent GPU abstraction devices.
[0123] The specific implementation process described in S202 of Embodiment 1 above will not be repeated here.
[0124] S402: Construct a two-layer driver architecture, design a general GPU abstraction layer, and standardize device interfaces and access operations, including whether GPU device attribute nodes are exposed, default read functions, write functions, and node permission setting functions, etc.
[0125] In this application, based on the general GPU abstraction layer, subsequent manufacturers can develop customized logic as needed, such as read or write functions for special protocols, and add functions not supported in the general GPU device attribute collection, etc.
[0126] S403: The BMC receives a registration request from the GPU device.
[0127] The specific implementation process described in S201 of Embodiment 1 above will not be repeated here.
[0128] S404: Enter the general GPU abstraction layer and configure the default state and default function corresponding to the general attribute node. The default function includes read function, write function and node permission setting function.
[0129] S405: After configuration, the GPU device is registered to the hwmon subsystem, and the hwmon device node is presented to the user layer.
[0130] S406: The user layer obtains the manufacturer ID and GPU device ID of the GPU device and determines the customized configuration information for each model of the GPU device.
[0131] The specific implementation process described in S203 of Embodiment 1 above will not be repeated here.
[0132] S407: If the actual state of the attribute node corresponding to the GPU device of this model is inconsistent with the default state, or any actual function used is inconsistent with the corresponding default function, then the actual state or actual function used is used to replace the corresponding inconsistent default state or default function in the registration function for modification, and the GPU device of this model is re-registered to the hwmon subsystem based on the modified registration function.
[0133] The specific implementation process described in Example 3 above will not be repeated here.
[0134] Figure 5 This application provides an embodiment of a process where the BMC accesses attribute nodes after a GPU device registration is completed. This process includes the following steps:
[0135] S501: BMC calls the read and write functions registered in the hwmon subsystem.
[0136] In this application, after the GPU device is registered, when the BMC accesses the attribute node, it calls the read and write functions in the registration function of the hwmon subsystem. Based on the called read and write functions, read and write operations are performed on the GPU device. That is, when the BMC user layer obtains or modifies the GPU device's temperature, power consumption, ID, speed, bandwidth, and other states, it does so by reading and writing the attribute nodes under the hwmon subsystem registered by the GPU device.
[0137] S502: Perform read and write operations on the GPU device according to the read and write functions, and return the real-time information corresponding to each attribute node.
[0138] After the user layer calls the read and write functions registered in the hwmon subsystem, it performs read and write operations on the GPU device according to these functions and returns real-time information corresponding to each attribute node. The read and write functions in the registration function may be generic read and write functions or specific read and write functions set by the manufacturer for this GPU device.
[0139] To facilitate understanding, the overall design concept of this application will be briefly introduced below.
[0140] Figure 6 A simplified process diagram illustrating a method for registering a GPU device provided in this application embodiment, the process including the following steps:
[0141] S601: In the hwmon subsystem, predefine the general attribute node for structure type GPU device and predeploy GPU devices.
[0142] During the development phase, attribute nodes of GPU devices from mainstream manufacturers can be pre-collected and organized. Manufacturer A serves as one of the sources for developing and designing GPU devices. Using the attribute nodes corresponding to manufacturer A's GPU devices as a benchmark, the specific attributes of each node of that GPU device are abstracted as common attributes, such as power consumption and temperature. The exposed state of each common attribute is then determined, and this exposed state is defined as the corresponding default state. Finally, the common attribute nodes of the GPU device and their corresponding default states are organized and saved to the common layer of the common GPU abstraction device according to the Linux hwmon subsystem specification. This is the specific implementation process described in S202 of Example 1 above, and will not be repeated here.
[0143] Figure 6a A simplified structural diagram of the pre-deployment of the hwmon subsystem provided in this application embodiment is shown below. Figure 6aAs shown, the researchers predefined a common attribute node for GPU devices and pre-deployed GPU devices in the hwmon subsystem. The common attribute node for GPU devices includes chip temperature, manufacturer ID, GPU device ID, board power consumption, etc.
[0144] S602: At the same time, in the general layer of the general GPU abstract device preset in the hwmon subsystem, GPU general information (gpu_common) is also configured, that is, the general GPU general layer is set. In addition to the default state of whether the general attribute node is exposed, the general layer also includes various default functions, such as the general read and write functions of the GPU device, the general node permission setting function, etc. Among them, the read and write functions include read functions and write functions.
[0145] Figure 6b A schematic diagram of the main contents of the general GPU common layer provided in the embodiments of this application, as shown below. Figure 6b As shown, it mainly includes: general read and write functions, including read and write functions, which do not involve manufacturer-defined communication protocols; node permission setting functions, used to determine the default state of attribute nodes; and defining an information structure, used to determine the general registration function between the GPU device and the hwmon subsystem, etc.
[0146] S603: Design vendor customization layer (gpu_vendor). In the vendor customization layer, the main configurations differ from those in the general GPU layer.
[0147] Figure 6c This is a schematic diagram illustrating possible differences in the embodiments of this application, such as... Figure 6c As shown, the differences that may occur in the vendor-customized layer include the actual state of the actual attribute nodes of the GPU device defined by the manufacturer, the read and write functions customized by the manufacturer, and the actual node permission setting functions, etc.
[0148] The specific implementation process described in S203 of Embodiment 1 above will not be repeated here.
[0149] S604: Determine the specific information of the GPU device and register the GPU device to the hwmon subsystem based on the specific information.
[0150] The specific implementation process described in S204 of Embodiment 1 above will not be repeated here.
[0151] S605: The BMC periodically acquires information and status of GPU devices that have completed driver registration.
[0152] This application analyzes and organizes information on GPU devices from major manufacturers, revealing that GPU devices from different manufacturers or different models from the same manufacturer share some common attributes, such as temperature and power. Therefore, this application standardizes device interfaces and access operations by adding a general-purpose GPU abstraction device, enabling compatibility with different GPU devices from different manufacturers, as well as different models from the same manufacturer. When registering customized GPU devices, only minor customization is required on the general-purpose GPU abstraction device to address inconsistencies, significantly reducing redundancy in GPU device development, increasing the reusability of GPU device monitoring processes, and improving the development efficiency of R&D personnel.
[0153] Example 7:
[0154] Based on the same technical concept and the above embodiments, this application provides an apparatus for GPU device registration. Figure 7 Please refer to the schematic diagram of a GPU device registration apparatus provided in this application embodiment. Figure 7 The device includes:
[0155] The receiving module 701 is configured to receive a registration request from a GPU device, wherein the registration request carries the manufacturer ID and GPU device ID of the GPU device;
[0156] The processing module 702 is used to call the default state of whether the pre-deployed general attribute nodes are exposed and each preset default function, and write the default state of whether the general attribute nodes are exposed and each preset default function into the registration function; determine the model of the GPU device according to the manufacturer ID and the GPU device ID; determine the actual state of whether the attribute nodes corresponding to the model of the GPU device are exposed and each actual function used; if the actual state of the attribute nodes corresponding to the model of the GPU device is inconsistent with the default state, or any of the actual functions used is inconsistent with the corresponding default function, then the actual state or the actual function used replaces the corresponding inconsistent default state or default function in the registration function for modification, and registers the model of the GPU device to the hwmon subsystem based on the modified registration function.
[0157] In one possible implementation, the processing module 702 is further configured to register the GPU device of the model to the hwmon subsystem based on the registration function if the actual state of the attribute node corresponding to the model GPU device is consistent with the default state, and each of the actual used functions is consistent with the corresponding default function.
[0158] In one possible implementation, the processing module 702 is further configured to register the GPU device to the hwmon subsystem based on the registration function;
[0159] The processing module 702 is specifically used to re-register the GPU device of the specified model to the hwmon subsystem based on the modified registration function.
[0160] In one possible implementation, the processing module 702 is specifically configured to determine the actual communication protocol used by the GPU device of the specified model for hardware monitoring data communication with the hwmon subsystem, based on a preset protocol mapping table and the model of the GPU device; and to determine the corresponding function set based on a preset function set mapping table and the actual communication protocol; wherein the functions in the function set are each actual function used by the GPU device of the specified model.
[0161] In one possible implementation, the default functions include read functions, write functions, and node permission setting functions.
[0162] Example 8:
[0163] Based on the same technical concept, this application also provides an electronic device. Figure 8 This application provides a schematic diagram of an electronic device structure, such as... Figure 8 As shown, it includes: processor 801, communication interface 802, memory 803 and communication bus 804, wherein processor 801, communication interface 802 and memory 803 communicate with each other through communication bus 804.
[0164] The memory 803 stores a computer program. When the program is executed by the processor 801, the processor 801 performs the following steps:
[0165] Receive a registration request from a GPU device, wherein the registration request carries the manufacturer ID and GPU device ID of the GPU device;
[0166] Invoke the default state of whether the pre-deployed general attribute nodes are exposed and the default function of each preset, and write the default state of whether the general attribute nodes are exposed and the default function of each preset into the registration function;
[0167] Based on the manufacturer ID and the GPU device ID, determine the model of the GPU device; determine the actual state of the attribute nodes corresponding to the GPU device model and the actual functions used;
[0168] If the actual state of the attribute node corresponding to the GPU device of the specified model is inconsistent with the default state, or any of the actual functions used are inconsistent with the corresponding default functions, then the actual state or the actual function used is used to replace the inconsistent default state or default function in the registration function for modification, and the GPU device of the specified model is registered to the hwmon subsystem based on the modified registration function.
[0169] In one possible implementation, the processor 801 is further configured to register the GPU device of the model to the hwmon subsystem based on the registration function if the actual state of the attribute node corresponding to the GPU device of the model is consistent with the default state, and each of the actual used functions is consistent with the corresponding default function.
[0170] In one possible implementation, the processor 801 is further configured to register the GPU device to the hwmon subsystem based on the registration function;
[0171] The processing module is specifically used to re-register the GPU device of the specified model into the hwmon subsystem based on the modified registration function.
[0172] In one possible implementation, the processor 801 is specifically configured to determine, based on a preset protocol mapping table and the model of the GPU device, the actual communication protocol used by the GPU device for hardware monitoring data communication with the hwmon subsystem; and to determine the corresponding function set based on a preset function set mapping table and the actual communication protocol; wherein the functions in the function set are each actual function used by the GPU device of the model.
[0173] In one possible implementation, the default functions include read functions, write functions, and node permission setting functions.
[0174] The communication bus mentioned in the above electronic devices can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.
[0175] Communication interface 802 is used for communication between the above-mentioned electronic device and other devices.
[0176] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0177] The processors mentioned above can be general-purpose processors, including central processing units, network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits, field-programmable gate arrays or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0178] Example 9:
[0179] Based on the same technical concept, embodiments of this application provide a computer-readable storage medium storing a computer program executable by a processor. When the program runs on the processor, it causes the processor to execute any of the GPU device registration methods described above. Since the principle by which the above-described computer-readable storage medium solves the problem is similar to that of a GPU device registration method, the implementation of the above-described computer-readable storage medium can be referred to the implementation of the method, and repeated details will not be repeated.
[0180] The aforementioned computer-readable storage medium can be any available medium or data storage device that can be accessed by the processor in an electronic device, including but not limited to magnetic storage such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), optical storage such as CDs, DVDs, BDs, HVDs, etc., and semiconductor storage such as ROMs, EPROMs, EEPROMs, non-volatile memory (NAND flash), solid-state drives (SSDs), etc.
[0181] Based on the same technical concept, this application also provides a computer program product, which includes computer program code. When the computer program code is run on a computer, it causes the computer to execute any of the above embodiments. Since the principle by which the above computer program product solves the problem is similar to the method for GPU device registration, the implementation of the above computer program product can refer to the implementation of the method, and repeated details will not be described again.
[0182] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0183] Computer programs used to perform the operations of this disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, status setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages such as Smalltalk, C++, etc., and conventional procedural programming languages such as the "C" language or similar programming languages. The computer-readable program instructions may execute entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer may be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or may be connected to an external computer (e.g., via the Internet using an Internet service provider). In some embodiments, electronic circuitry, such as programmable logic circuitry, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs), is personalized by utilizing status information from the computer-readable program instructions to implement various aspects of this disclosure.
[0184] The computer program product described herein can be implemented specifically through hardware, software, or a combination thereof. In one alternative embodiment, the computer program product is specifically embodied in a computer storage medium; in another alternative embodiment, the computer program product is specifically embodied in a software product, such as a software development kit (SDK), etc.
[0185] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0186] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0187] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0188] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.
[0189] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A method for registering a GPU device, characterized in that, The method includes: Receive a registration request from a GPU device, wherein the registration request carries the manufacturer ID and GPU device ID of the GPU device; Invoke the default state of whether the pre-deployed general attribute nodes are exposed and the default function of each preset, and write the default state of whether the general attribute nodes are exposed and the default function of each preset into the registration function; Based on the manufacturer ID and the GPU device ID, determine the model of the GPU device; determine the actual state of the attribute nodes corresponding to the GPU device model and the actual functions used; If the actual state of the attribute node corresponding to the GPU device of the specified model is inconsistent with the default state, or any of the actual functions used are inconsistent with the corresponding default functions, then the actual state or the actual function used is used to replace the inconsistent default state or default function in the registration function for modification, and the GPU device of the specified model is registered to the hwmon subsystem based on the modified registration function.
2. The method according to claim 1, characterized in that, The method further includes: If the actual state of the attribute node corresponding to the GPU device of the specified model is consistent with the default state, and each of the actual functions used is consistent with the corresponding default function, then the GPU device of the specified model is registered to the hwmon subsystem based on the registration function.
3. The method according to claim 1, characterized in that, After writing the default state of whether the general attribute node is exposed and each preset default function into the registration function, and before determining the model of the GPU device based on the manufacturer ID and the GPU device ID, the method further includes: The GPU device is registered to the hwmon subsystem based on the registration function; Registering the GPU device of the aforementioned model to the hwmon subsystem based on the modified registration function includes: The modified registration function re-registers the GPU device of the aforementioned model into the hwmon subsystem.
4. The method according to claim 1, characterized in that, The process of determining the GPU device model corresponding to each actual function includes: Based on the preset protocol mapping table and the model of the GPU device, determine the actual communication protocol used by the GPU device of the specified model to perform hardware monitoring data communication with the hwmon subsystem; Based on a preset function set mapping table and the actual communication protocol, a corresponding function set is determined; wherein the functions in the function set are each actual function used by the GPU device of the specified model.
5. The method according to claim 1, characterized in that, The default functions include read functions, write functions, and node permission setting functions.
6. An apparatus for registering a GPU device, characterized in that, The device includes: The receiving module is configured to receive a registration request from a GPU device, wherein the registration request carries the manufacturer ID and GPU device ID of the GPU device; The processing module is used to call the default state of whether the pre-deployed general attribute nodes are exposed and each preset default function, and write the default state of whether the general attribute nodes are exposed and each preset default function into the registration function; determine the model of the GPU device according to the manufacturer ID and the GPU device ID; determine the actual state of whether the attribute nodes corresponding to the model of the GPU device are exposed and each actual function used; if the actual state of the attribute node corresponding to the model of the GPU device is inconsistent with the default state, or any of the actual functions used is inconsistent with the corresponding default function, then the actual state or the actual function used replaces the corresponding inconsistent default state or default function in the registration function for modification, and registers the model of the GPU device to the hwmon subsystem based on the modified registration function.
7. The apparatus according to claim 6, characterized in that, The processing module is further configured to register the GPU device of the specified model to the hwmon subsystem based on the registration function if the actual state of the attribute node corresponding to the GPU device of the specified model is consistent with the default state, and each actual function used is consistent with the corresponding default function.
8. The apparatus according to claim 6, characterized in that, The processing module is further configured to register the GPU device to the hwmon subsystem based on the registration function; The processing module is specifically used to re-register the GPU device of the specified model into the hwmon subsystem based on the modified registration function.
9. An electronic device, characterized in that, The electronic device includes a processor that executes a computer program stored in a memory to implement the GPU device registration method as described in any one of claims 1-5.
10. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed by a processor, implements the GPU device registration method as described in any one of claims 1-5.