Device driving method, device and electronic device
By detecting the replacement and replacement of drivers of FPGA devices, reading device information for registration, and separating the software layer, the complexity of FPGA device adaptation management of different manufacturers is solved, and the effect of simplifying management and adapting to multiple manufacturers is achieved.
Patent Information
- Application Number
- CN202211452788.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-21
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2042-11-21
AI Technical Summary
The prior art is difficult to realize adaptation management without changing the device acceleration program when replacing FPGA devices from different manufacturers, resulting in increased management complexity.
By detecting the replacement of FPGA equipment, identifying the manufacturer's logo and replacing the driver, reading the device information for registration, separating the driver software layer into the management module and the driver module, and using the same management module to adapt to FPGA equipment from different manufacturers.
It realizes that when replacing FPGA devices from different manufacturers, you only need to replace the driver to keep the device acceleration program unchanged, simplify the management process, and adapt to FPGA devices from multiple manufacturers.
Smart Images

Figure CN115718625B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present disclosure relate to the field of computer technology, and more particularly to a device driving method, apparatus, and electronic device. Background Art
[0002] Companies with large-scale data centers, such as large internet companies and telecommunications companies, often have computer rooms across the country and even around the world that provide services to users. One of the trends in the development of these data centers is the use of computing devices such as FPGAs (Field Programmable Gate Arrays) to reduce costs and improve performance. Summary of the Invention
[0003] This disclosure section is provided to briefly introduce concepts that will be described in detail in the detailed description section below. This disclosure section is not intended to identify key features or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.
[0004] In a first aspect, an embodiment of the present disclosure provides a device driving method, comprising: in response to detecting that a target device inserted into a target interface has been replaced, determining whether the current target device is the same as the target device before the replacement, wherein the target device is a field programmable logic gate array device; if not, replacing the driver with the driver corresponding to the current target device; reading the device information of the current target device, and registering the current target device using the device information.
[0005] In a second aspect, an embodiment of the present disclosure provides a device driver device, comprising: a determination unit, for determining whether the current target device is the same as the target device before replacement in response to detecting that the target device inserted into the target interface has been replaced, wherein the target device is a field programmable logic gate array device; a replacement unit, for replacing the driver with the driver corresponding to the current target device if the current target device is not the same as the target device before replacement; and a registration unit, for reading the device information of the current target device and registering the current target device using the device information.
[0006] In a third aspect, an embodiment of the present disclosure provides an electronic device, comprising: at least one processor; a storage device for storing at least one program, wherein when the at least one program is executed by the at least one processor, the at least one processor implements the device driving method as described in the first aspect.
[0007] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the device driving method as described in the first aspect.
[0008] The device driver method, apparatus, and electronic device provided by the embodiments of the present disclosure determine whether the current target device is the same as the target device before the replacement in response to detecting that the FPGA device plugged into the target interface has been replaced. If not, the driver is replaced with the driver corresponding to the current target device. Thereafter, the device information of the current target device is read and the current target device is registered using the device information. In this way, when replacing an FPGA device from a different manufacturer, only the driver of the FPGA device needs to be replaced. The same management module can be used for registration and management of different FPGA devices without changing the device acceleration program, thereby adapting to FPGA devices from multiple manufacturers. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] The above and other features, advantages, and aspects of the various embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and that the originals and elements are not necessarily drawn to scale.
[0010] Figure 1 is a flow chart of an embodiment of a device driving method according to the present disclosure;
[0011] Figure 2 is a schematic diagram of an application scenario of the device driving method according to the present disclosure;
[0012] Figure 3 is a flowchart of an embodiment of sending a command to an FPGA device in a device driver method according to the present disclosure;
[0013] Figure 4 This is a flowchart of an embodiment of releasing resources when a thread exits abnormally in a device driver method according to the present disclosure;
[0014] Figure 5 is a flowchart of an embodiment of allocating instances to sessions in a device driver method according to the present disclosure;
[0015] Figure 6 is a flowchart of another embodiment of allocating an instance to a session in a device driver method according to the present disclosure;
[0016] Figure 7 is a structural diagram of an embodiment of a device driving apparatus according to the present disclosure;
[0017] Figure 8 is an exemplary system architecture diagram in which various embodiments of the present disclosure may be applied;
[0018] Figure 9It is a structural diagram of a computer system suitable for implementing the electronic device of the embodiment of the present disclosure. DETAILED DESCRIPTION
[0019] The following describes embodiments of the present disclosure in more detail with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as limited to the embodiments described herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of protection of the present disclosure.
[0020] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0021] As used herein, the term "including" and its variations are open-ended, i.e., "including but not limited to." The term "based on" means "based, at least in part, on." The term "one embodiment" means "at least one embodiment," the term "another embodiment" means "at least one additional embodiment," and the term "some embodiments" means "at least some embodiments." Other terms are defined in the following description.
[0022] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0023] It should be noted that the modifications of "one" and "multiple" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, they should be understood as "one or more".
[0024] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0025] Please refer to Figure 1 , shows a process 100 of an embodiment of a device driver method according to the present disclosure. The device driver method includes the following steps:
[0026] Step 101: In response to detecting that a target device plugged into a target interface has been replaced, determine whether the current target device is the same as the target device before the replacement. In this embodiment, the execution body of the device driver method can detect whether the target device plugged into the target interface has been replaced. The target device typically refers to a field programmable gate array (FPGA) device. The target interface typically refers to the interface plugged into the FPGA device.
[0027] Here, the hardware acceleration capabilities of the FPGA device are made available to the business scenario. The business scenario sends data to the FPGA device for calculation and processing, and after the FPGA device completes the processing, it retrieves the results, completing the hardware acceleration process.
[0028] If it is detected that the target device inserted into the above target interface has been replaced, that is, it is detected that the FPGA device inserted into the above target interface has been unplugged and then another FPGA device is inserted, the above execution entity can determine whether the current target device is the same as the target device before replacement.
[0029] Specifically, the above-mentioned execution subject can identify the identifier corresponding to the current target device. Here, the above-mentioned identifier can include the manufacturer identifier of the manufacturer to which the FPGA device belongs, and can also include the device identifier of the FPGA device. Since FPGA devices produced by different manufacturers are usually driven by different drivers, it is necessary to identify the manufacturer identifier of the manufacturer to which the FPGA device belongs, and the manufacturer identifier corresponds to the driver that drives the FPGA device. The above-mentioned execution subject can determine whether the identifier corresponding to the current target device is consistent with the identifier corresponding to the target device before replacement. That is, it is determined whether the target device after replacement and the target device before replacement belong to the same manufacturer. If they are consistent, it means that the current target device and the target device before replacement belong to the same manufacturer. At this time, there is no need to replace the driver corresponding to the device. If they are inconsistent, the above-mentioned execution subject can determine that the current target device is different from the target device before replacement.
[0030] If they are the same, the execution entity may execute step 102 .
[0031] Here, we can create corresponding software layers based on the FPGA hardware logic layering, and more rationally break down software functions. The device driver can be separated into two independent software layers: the first layer is the PCIE (Peripheral Component Interconnect Express, a high-speed serial computer expansion bus standard) & DMA (Direct Memory Access) driver module (corresponding to the driver program), and the second layer is the management module (corresponding to the device acceleration program). There is no coupling between the two layers.
[0032] Step 102: If they are not the same, the driver is replaced with the driver corresponding to the current target device.
[0033] In this embodiment, if the current target device is different from the target device before replacement, the execution entity may replace the driver with the driver corresponding to the current target device. Specifically, the execution entity may obtain the driver corresponding to the current target device and use the driver corresponding to the current target device to replace the driver corresponding to the target device before replacement, while maintaining the device acceleration program. In this context, the device acceleration program is typically used to control the acceleration function of the FPGA device. The driver corresponding to the current target device can then be used to drive the replaced target device to perform data calculation and processing.
[0034] Step 103: Read the device information of the current target device and register the current target device using the device information.
[0035] In this embodiment, the execution entity can read the device information of the current target device through the driver. This device information may include a device identifier, an instance stored in the device, and so on. The current target device can then be registered with a management module. After obtaining the device information of the current target device, the management module manages the current target device based on the device information. The management module is typically used to manage sessions, resources, and commands.
[0036] The method provided by the above-mentioned embodiment of the present disclosure determines whether the current target device is the same as the target device before the replacement in response to detecting that the FPGA device plugged into the target interface has been replaced. If not, the driver is replaced with the driver corresponding to the current target device. Thereafter, the device information of the current target device is read and the current target device is registered using the device information. In this way, when replacing FPGA devices from different manufacturers, only the driver of the FPGA device needs to be replaced. The same management module can be used for registration and management of different FPGA devices without changing the device acceleration program, thus adapting to FPGA devices from multiple manufacturers.
[0037] Continue to see Figure 2 , Figure 2 This is a schematic diagram of an application scenario of the device driver method according to this embodiment. Figure 2In the application scenario, icon 201 indicates the software layer that implements the device driver, including management module 2011 and driver module 2012. Management module 2011 is generally used to manage sessions and resources, including but not limited to recording user-requested resources and issued commands, queuing commands, receiving notifications and releasing corresponding hardware resources when a thread exits abnormally, maintaining the instance pool, and balancing the load of each instance. Driver module 2012 is generally used to drive the FPGA device using the PCIE & DMA engine.
[0038] Icon 202 indicates an FPGA device, which includes a Shell layer 2021 and a hardware acceleration layer 2022. The Shell layer 2021 is built-in by the manufacturer (or the company's basic hardware team), and plays the role of a hardware device interface, serving as a data and command path between the host. The hardware acceleration layer 2022 is developed by the customer (or the company's business acceleration team) and is responsible for actual data calculation and processing. The relationship between the Shell layer 2021 and the hardware acceleration layer 2022 is like the relationship between a road and a factory. The Shell layer 2021 is responsible for connection and transportation, and the hardware acceleration layer 2022 is responsible for processing, such as compression, encryption, video encoding, and other processing.
[0039] Icon 203 indicates an API (Application Programming Interface), which is used to implement interaction with the business layer 204. The API includes a hardware acceleration API indicated by icon 2031 and session, resource, and command APIs indicated by icon 2032.
[0040] Icon 204 indicates the business layer, which processes operations performed by users or commands issued by users.
[0041] The FPGA device 202 receives data and commands sent by the device driver software layer 201 . The device driver software layer 201 may wait for the FPGA device 202 to complete the command and retrieve the processed data.
[0042] In this way, the device driver software layer is divided into a management module and a driver module. A management module can be connected to multiple FPGA devices from different manufacturers. By replacing the driver programs corresponding to different FPGA devices, the management module can be connected without changing the device's management module, API, and business layer.
[0043] Further references Figure 3 , which shows a process 300 of an embodiment of sending a command to an FPGA device in a device driver method. The process 300 of sending a command to an FPGA device includes the following steps:
[0044] Step 301: Detect whether there are at least two threads using a session to send commands to the current target device.
[0045] In this embodiment, the execution body of the device driver method can detect whether there are at least two threads using a session to send commands to the current FPGA device. Before each thread uses the device acceleration function, it is generally necessary to establish a session with the FPGA device and use the device acceleration function provided by the FPGA device through the session.
[0046] A thread is the smallest unit of computational scheduling within an operating system. It is contained within a process and serves as the actual operational unit within that process. A thread is a single, sequential flow of control within a process. A process can have multiple threads running concurrently, each executing different tasks in parallel.
[0047] If it is detected that at least two threads use the session to send commands to the current target device, the execution entity may execute step 302 .
[0048] Step 302: If it is detected that at least two threads use the session to send commands to the current target device, the at least two commands are sorted, and the commands are sent to the current target device according to the sorting result.
[0049] In this embodiment, if at least two threads are detected in step 301 to be sending commands to the current target device using the session, the execution entity may sort the at least two commands and then send the commands to the current target device according to the sorting result. As an example, the execution entity may sort the at least two commands in order of command issuance time, so that the command with the earlier command issuance time is sent to the current target device first, and the command with the later command issuance time is sent to the current target device later.
[0050] Here, sessions can be managed by the management module ( Figure 2 The FPGA device manages all resources requested and commands issued by users in a session. When at least two threads issue commands to the current FPGA device through their respective sessions, the management module can sort these commands and then send them to the FPGA device for execution based on the sorting results.
[0051] The method provided by the above-mentioned embodiment of the present disclosure supports multi-threaded high-concurrency use of the same FPGA device by sorting at least two commands sent to the FPGA device and handing the commands to the FPGA device for execution in sequence according to the sorting results.
[0052] Continue to refer Figure 4, which shows a process 400 of an embodiment of releasing resources when a thread exits abnormally in a device driver method. The process 400 of releasing resources when a thread exits abnormally includes the following steps:
[0053] Step 401: Determine whether a notification indicating abnormal thread exit is received.
[0054] In this embodiment, the execution subject of the device driver method can determine whether it has received a notification indicating that a thread has exited abnormally. Here, the execution subject usually manages the session in a management module. Since the management module is in kernel mode, the management module can be notified regardless of whether the process exits normally or abnormally.
[0055] Kernel state, also known as management state, kernel space, or kernel mode, contrasts with user state or user mode. A CPU (Central Processing Unit) in kernel state can access any data, including peripherals such as network cards and hard drives. A CPU in kernel state can switch from one program to another without preemption. The state typically at privilege level 0 is called kernel state.
[0056] If it is determined that a notification indicating abnormal thread exit is received, the execution entity may execute step 402 .
[0057] Step 402: If a notification indicating that a thread has exited abnormally is received, resources of the target device used by the session corresponding to the thread that has exited abnormally are released.
[0058] In this embodiment, if a notification indicating that a thread has exited abnormally is received in step 401, the execution entity may release the target device resources used by the session corresponding to the abnormally exited thread. After receiving the notification of the abnormal thread exit, the management module may release the hardware resources used by the corresponding session.
[0059] The method provided by the above embodiment of the present disclosure can release the hardware resources used by the corresponding session after receiving the notification of abnormal exit of the thread, so that the hardware resources can continue to be used by other threads.
[0060] Further references Figure 5 , which shows a process 500 of an embodiment of allocating an instance to a session in a device driver method. The process 500 of allocating an instance to a session includes the following steps:
[0061] Step 501: Determine whether to create a session between the thread and the current target device.
[0062] In this embodiment, writing the hardware acceleration code into the FPGA device to create executable logic is called instantiation. This executable logic is called an instance, and each instance independently runs the hardware acceleration code. If the hardware resources are large and the specifications are high, multiple instances can be instantiated. Currently, an FPGA device can store at least two instances.
[0063] Here, instances are typically used to implement device acceleration functions such as compression, encryption, and video decoding of input data.
[0064] In this embodiment, the execution subject of the device driver method can determine whether to establish a session between the thread and the current FPGA device. Before each thread uses the device acceleration function, it is usually necessary to establish a session with the FPGA device to use the device acceleration function provided by the FPGA device through the session.
[0065] If it is determined that a session between the creation thread and the current target device is to be created, the execution subject may execute step 502 .
[0066] Step 502: If a session between the thread and the current target device is created, an instance to be used is allocated to the created session in at least two instances.
[0067] In this embodiment, if a session between the creation thread and the current target device is determined in step 501, the execution entity may allocate an instance to be used for the created session from the at least two instances. Here, the execution entity typically utilizes a management module to maintain an instance pool of inserted FPGA devices and the load of each instance. After the session is created, an instance is selected from the at least two instances of the FPGA device (e.g., an instance corresponding to an idle state) for allocation to achieve load balancing for each instance.
[0068] The method provided by the above-mentioned embodiment of the present disclosure allocates instances to the newly created session after the session is created, thereby load balancing the instances and making full use of the hardware capabilities of the FPGA device.
[0069] Continue to refer Figure 6 , which shows a process 600 of another embodiment of allocating an instance to a session in a device driver method. The process 600 of allocating an instance to a session includes the following steps:
[0070] Step 601: Obtain the number of instances stored in the current target device, and obtain the number of sessions between the thread and the current target device.
[0071] In this embodiment, the executor of the device driver method can obtain the number of instances stored in the current target device. Writing hardware acceleration code into an FPGA device to transform it into executable logic is called instantiation. This executable logic is an instance, and each instance independently runs the hardware acceleration code. If the hardware resources are abundant and large in size, multiple instances can be instantiated. Current FPGA devices typically store multiple instances. Instances are typically used to implement device acceleration functions such as input data compression, encryption, and video decoding.
[0072] Afterwards, the execution subject can obtain the number of sessions between the thread and the current target device. Before each thread uses the device acceleration function, it is usually necessary to establish a session with the FPGA device to use the device acceleration function provided by the FPGA device through the session.
[0073] Step 602: Allocate instances to sessions using the number of instances and the number of sessions to balance the load of each instance.
[0074] In this embodiment, the execution entity may use the number of instances and the number of sessions to assign instances to sessions, thereby balancing the load on each instance. Specifically, the execution entity may evenly assign sessions to instances so that each instance processes substantially the same number of sessions, thereby balancing the load on each instance.
[0075] The method provided by the above-mentioned embodiments of the present disclosure can load balance instances and fully utilize the hardware capabilities of FPGA devices.
[0076] Further references Figure 7 As an implementation of the methods shown in the above figures, the present application provides an embodiment of a device driver. Figure 1 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0077] like Figure 7 As shown, the device driver apparatus 700 of this embodiment includes: a determination unit 701, a replacement unit 702, and a registration unit 703. The determination unit 701 is configured to, in response to detecting that a target device inserted into a target interface has been replaced, determine whether the current target device is the same as the target device before replacement, wherein the target device is a field programmable gate array device; the replacement unit 702 is configured to replace the driver with the driver corresponding to the current target device if the current target device is different from the target device before replacement; and the registration unit 703 is configured to read device information of the current target device and register the current target device using the device information.
[0078] In this embodiment, the specific processing of the determining unit 701, the replacing unit 702 and the registering unit 703 of the device driver 700 can be referred to. Figure 1 This corresponds to step 101, step 102 and step 103 in the embodiment.
[0079] In some optional implementations, the device driver 700 further includes a sorting unit (not shown). The sorting unit may be configured to, in response to detecting that at least two threads are sending commands to the current target device using a session, sort the at least two commands and send the commands to the current target device according to the sorting result.
[0080] In some optional implementations, the device driver 700 further includes a resource release unit (not shown). The resource release unit may be configured to release resources of a target device used by a session corresponding to the abnormally exited thread in response to receiving a target notification, wherein the target notification indicates that the thread has abnormally exited.
[0081] In some optional implementations, the current target device stores at least two instances, and the device driver 700 further includes a first allocation unit (not shown). The first allocation unit may be configured to allocate an instance to be used for the created session from the at least two instances in response to creating a session between the thread and the current target device.
[0082] In some optional implementations, the device driver 700 further includes: an acquisition unit (not shown in the figure) and a second allocation unit (not shown in the figure). The acquisition unit may be configured to acquire the number of instances stored in the current target device and the number of sessions between the acquisition thread and the current target device; the second allocation unit may be configured to allocate instances to the sessions using the number of instances and the number of sessions, thereby balancing the load of each instance.
[0083] Please refer to Figure 8 , Figure 8 An exemplary system architecture is shown in which the device driving method according to one embodiment of the present disclosure can be applied.
[0084] like Figure 8As shown, the system architecture may include electronic devices 801 and 802, and an FPGA device 803. Communication between electronic devices 801 and 802 and FPGA device 803 is typically achieved via a high-speed bus. Specifically, electronic devices 801 and 802 are typically provided with an interface into which the FPGA device can be inserted. By inserting the FPGA device into this interface, electronic devices 801 and 802 and FPGA device 803 can interact via the high-speed bus by reading and writing memory or performing direct memory access. Here, the high-speed bus may include PCIE (Peripheral Component Interconnect Express, a high-speed serial computer expansion bus standard).
[0085] The electronic devices 801 and 802 can interact with the FPGA device 803 to send or receive messages, etc. For example, the electronic devices 801 and 802 can send commands to the FPGA device.
[0086] Electronic devices 801 and 802 can be hardware or software. When electronic devices 801 and 802 are hardware, they can include but are not limited to electronic devices with an interface for inserting FPGA devices, such as servers, tablet computers, and laptop computers. When electronic devices 801 and 802 are software, they can be installed in the electronic devices listed above. They can be implemented as multiple software or software modules (for example, multiple software or software modules for providing distributed services), or they can be implemented as a single software or software module. No specific limitation is made here.
[0087] Electronic devices 801 and 802 can, in response to detecting that the FPGA device inserted into the target interface has been replaced, determine whether the current FPGA device is the same as the FPGA device before the replacement; if not, replace the driver with the driver corresponding to the current FPGA device; thereafter, read the device information of the above-mentioned current FPGA device and use the above-mentioned device information to register the above-mentioned current FPGA device.
[0088] It should be noted that the device driving method provided in the embodiment of the present disclosure is usually executed by the electronic devices 801 and 802 , and accordingly, the device driving apparatus is usually provided in the electronic devices 801 and 802 .
[0089] It should be understood that Figure 8 The number of electronic devices and FPGA devices in the embodiment is only illustrative. Any number of electronic devices and FPGA devices may be provided according to implementation requirements.
[0090] Reference below Figure 9 , which shows an electronic device (eg Figure 8The terminal device in the embodiments of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (such as in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 9 The electronic device shown is only an example and should not limit the functions and scope of use of the embodiments of the present disclosure.
[0091] like Figure 9 As shown, the electronic device may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage device 908 into a random access memory (RAM) 903. Various programs and data required for the operation of the electronic device 900 are also stored in the RAM 903. The processing device 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.
[0092] Typically, the following devices may be connected to the I / O interface 905: an input device 906 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 907 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 908 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 909. The communication device 909 may allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Although Figure 9 The electronic device is shown with various devices, but it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed instead.
[0093] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 909, or installed from the storage device 908, or installed from the ROM 902. When the computer program is executed by the processing device 901, the above-mentioned functions defined in the method of the embodiment of the present disclosure are performed.
[0094] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, device, or component. In the present disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to wires, optical cables, RF (radio frequency), etc., or any suitable combination thereof.
[0095] In some embodiments, the client and server can communicate using any currently known or future developed network protocol, such as HTTP (HyperText Transfer Protocol), and can be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0096] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0097] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: in response to detecting that the target device inserted into the target interface has been replaced, determines whether the current target device is the same as the target device before the replacement, wherein the target device is a field programmable logic gate array device; if not, replaces the driver with the driver corresponding to the current target device; reads the device information of the current target device, and registers the current target device using the device information.
[0098] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including, but not limited to, object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on the remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through 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., through the Internet using an Internet service provider).
[0099] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of the boxes in the block diagram and / or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0100] The units described in the embodiments of the present disclosure may be implemented in software or hardware. In some cases, the name of a unit does not limit the unit itself. For example, a registration unit may be described as "a unit that reads device information of a current target device and registers the current target device using the device information."
[0101] The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, and without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chip (SOCs), complex programmable logic devices (CPLDs), and the like.
[0102] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0103] According to one or more embodiments of the present disclosure, a device driver method is provided, which includes: in response to detecting that a target device inserted into a target interface has been replaced, determining whether the current target device is the same as the target device before the replacement, wherein the target device is a field programmable gate array device; if they are not the same, replacing the driver with the driver corresponding to the current target device; reading device information of the current target device, and registering the current target device using the device information.
[0104] According to one or more embodiments of the present disclosure, the method further includes: in response to detecting that at least two threads use a session to send commands to the current target device, sorting the at least two commands, and sending commands to the current target device according to the sorting result.
[0105] According to one or more embodiments of the present disclosure, the method further includes: in response to receiving a target notification, releasing resources of a target device used by a session corresponding to the abnormally exited thread, wherein the target notification indicates that the thread has abnormally exited.
[0106] According to one or more embodiments of the present disclosure, the current target device stores at least two instances; and the method further includes: in response to creating a session between the thread and the current target device, allocating an instance to be used for the created session in the at least two instances.
[0107] According to one or more embodiments of the present disclosure, the method further includes: obtaining the number of instances stored in the current target device, and obtaining the number of sessions between the thread and the current target device; using the number of instances and the number of sessions, allocating instances to the sessions and balancing the load of each instance.
[0108] According to one or more embodiments of the present disclosure, a device driver apparatus is provided, comprising: a determination unit for determining, in response to detecting that a target device inserted into a target interface has been replaced, whether a current target device is the same as a target device before replacement, wherein the target device is a field programmable gate array device; a replacement unit for replacing a driver with a driver corresponding to the current target device if the current target device is different from the target device before replacement; and a registration unit for reading device information of the current target device and registering the current target device using the device information.
[0109] According to one or more embodiments of the present disclosure, the apparatus further includes: a sorting unit for sorting the at least two commands in response to detecting that at least two threads send commands to the current target device using a session, and sending commands to the current target device according to the sorting result.
[0110] According to one or more embodiments of the present disclosure, the apparatus further includes: a resource releasing unit for releasing resources of a target device used by a session corresponding to the abnormally exited thread in response to receiving a target notification, wherein the target notification indicates that the thread has abnormally exited.
[0111] According to one or more embodiments of the present disclosure, the current target device stores at least two instances; and the apparatus further includes: a first allocation unit for allocating an instance used for the created session in the at least two instances in response to creating a session between the thread and the current target device.
[0112] According to one or more embodiments of the present disclosure, the device also includes: an acquisition unit, used to obtain the number of instances stored in the current target device, and the number of sessions between the acquisition thread and the current target device; a second allocation unit, used to use the number of instances and the number of sessions to allocate instances to sessions and balance the load of each instance.
[0113] The above description is merely a preferred embodiment of the present disclosure and an illustration of the technical principles employed. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by the specific combination of the above-mentioned technical features, but also includes other technical solutions formed by any combination of the above-mentioned technical features or their equivalents without departing from the above-mentioned disclosed concepts. For example, a technical solution formed by replacing the above-mentioned features with (but not limited to) technical features with similar functions disclosed in this disclosure.
[0114] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details have been included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0115] Although the subject matter has been described in language specific to structural features and / or methodological logical acts, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms of implementing the claims.
Claims
1. A device driving method, characterized in that: include: In response to detecting that a target device inserted into a target interface has been replaced, determining whether the current target device is the same as the target device before the replacement, wherein the target device is a field programmable gate array device, the target interface is an interface inserted into the target device, and detecting that the target device inserted into the target interface has been replaced includes: detecting that the target device inserted into the target interface is unplugged and then another target device is inserted; If they are not the same, the driver will be replaced with the driver corresponding to the current target device; Reading device information of the current target device, and registering the current target device using the device information; The device driver software layer includes a management module and a driver module. The management module manages target devices from different manufacturers and adapts target devices from different manufacturers by replacing the driver program through the driver module. The management module remains unchanged. The device information includes parameters of the hardware acceleration layer in the current target device and the number of stored instances. Registration includes integrating the hardware acceleration layer parameters and the number of instances into the management module so that the management module can allocate instances to thread sessions and balance loads.
2. The method according to claim 1, characterized in that The method further comprises: In response to detecting that at least two threads use a session to send commands to the current target device, the at least two commands are sorted, and commands are sent to the current target device according to the sorting result.
3. The method according to claim 1, characterized in that The method further comprises: In response to receiving a target notification indicating that the thread exited abnormally, resources of a target device used by a session corresponding to the thread that exited abnormally are released.
4. The method according to claim 1, wherein The current target device stores at least two instances; as well as The method further comprises: In response to creating a session between the thread and the current target device, an instance to be used is allocated to the created session among the at least two instances.
5. The method according to claim 1, characterized in that The method further comprises: Obtaining the number of instances stored in the current target device and the number of sessions between the thread and the current target device; Instances are allocated to the sessions using the number of instances and the number of sessions, so as to balance the load of each instance.
6. A device driving apparatus, characterized in that: include: a determining unit configured to, in response to detecting that a target device inserted into a target interface has been replaced, determine whether a current target device is the same as a target device before the replacement, wherein the target device is a field programmable gate array device, the target interface is an interface inserted into the target device, and detecting that the target device inserted into the target interface has been replaced comprises: detecting that the target device inserted into the target interface is unplugged and then another target device is inserted; a replacement unit, configured to replace the driver with a driver corresponding to the current target device if the current target device is different from the target device before replacement; a registration unit, configured to read device information of the current target device and register the current target device using the device information; The device driver software layer includes a management module and a driver module. The management module manages target devices from different manufacturers and adapts target devices from different manufacturers by replacing the driver program through the driver module. The management module remains unchanged. The device information includes parameters of the hardware acceleration layer in the current target device and the number of stored instances. Registration includes integrating the hardware acceleration layer parameters and the number of instances into the management module so that the management module can allocate instances to thread sessions and balance loads.
7. The device according to claim 6, characterized in that The device further comprises: The sorting unit is configured to, in response to detecting that at least two threads send commands to the current target device using a session, sort the at least two commands and send commands to the current target device according to the sorting result.
8. The device according to claim 6, characterized in that The device further comprises: The resource releasing unit is configured to release resources of a target device used by a session corresponding to a thread that exits abnormally in response to receiving a target notification, wherein the target notification indicates that the thread exits abnormally.
9. An electronic device, characterized in that: include: at least one processor; a storage device having at least one program stored thereon, When the at least one program is executed by the at least one processor, the at least one processor implements the method according to any one of claims 1 to 5.
10. A computer-readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Tuner drive control method and device
CN106028113A
Communication mode implementation method and electronic device
CN110008032A
Hardware acceleration equipment mounting method and cloud platform
CN111240800A
DPDK driving system based on FPGA accelerator card
CN113419780A