OpenCL calculation offloading method, device and storage medium
By creating a virtual vsock transmission device and starting the pocld daemon when the virtual machine starts, combined with the socket function to process the connection request, and using the pocl parsing address parsing function to parse the calculation instructions, the high-speed communication and OpenCL computing in the multi-virtual machine scenario are realized. Computing offloading solves the problem in the existing technology that OpenCL computing cannot be applied to cloud computing multi-virtual machine scenarios, and improves configuration flexibility and security.
Patent Information
- Application Number
- CN202410888028.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-04
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2044-07-04
AI Technical Summary
Existing OpenCL computing cannot be applied to multi-virtual machine scenarios in cloud computing, cannot be transparently transmitted to each virtual machine at the same time, and the configuration is inflexible.
Create a virtual vsock transmission device when the virtual machine starts, start the pocld daemon and generate the address data of the address cluster, combine the socket function to generate a read socket connection thread, and use the modified pocl parsing address parsing function to analyze the received vsock information Perform analysis to achieve high-speed communication between the host and multiple virtual machines, and offload OpenCL calculations to devices with computing capabilities for calculation.
To implement OpenCL computing offloading in cloud computing scenarios, applications can use the host-side acceleration device for acceleration just like local devices, reducing additional configuration and improving security.
Smart Images

Figure CN118445030B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of open computing language technology, and in particular to an OpenCL computing offloading method, device and storage medium. Background Art
[0002] OpenCL is an open, standard programming language for writing portable, parallel, high-performance computing applications. It allows applications to use CPUs, GPUs, FPGAs, and other accelerators to perform computing tasks.
[0003] Traditionally, OpenCL computations have been limited to local machines. However, with the widespread adoption of cloud computing, virtual machines (VMs) have become a crucial computing resource. Using OpenCL for computations within VMs can improve resource utilization and reduce costs. GPU passthrough can be used to transparently transmit the host's GPU directly to the VM, turning it into a VM device. However, this approach cannot transparently transmit to each VM simultaneously when used with multiple VMs in cloud computing, nor can it flexibly adapt to each VM, requiring manual passthrough configuration. Summary of the Invention
[0004] The embodiments of the present invention provide an OpenCL calculation offloading method, device and storage medium to solve the technical problem in the prior art that OpenCL calculations cannot be applied to cloud computing multi-virtual machine scenarios.
[0005] In a first aspect, an embodiment of the present invention provides an OpenCL computation offloading method, comprising:
[0006] When the virtual machine is started, a virtual vsock transmission device is created for the virtual machine using a virtual device creation command;
[0007] The computing party starts the pocld daemon based on the incoming listening address and generates the address data of the address cluster;
[0008] Based on the address data and in combination with the socket function, a socket connection reading thread is generated to process the connection request of the client;
[0009] The vsock information received after the connection is parsed using the parsing function that modifies the pocl parsing address to obtain a calculation instruction, so that the Pocl daemon program receives the calculation instruction and processes the calculation instruction using its own resources to obtain a calculation result.
[0010] In a second aspect, an embodiment of the present invention further provides an OpenCL calculation offloading device, comprising:
[0011] A creation module, configured to create a virtual vsock transmission device for the virtual machine using a virtual device creation command when the virtual machine is started;
[0012] The startup module is used to enable the computing party to start the pocld daemon based on the incoming listening address and generate the address data of the address cluster;
[0013] A combining module, configured to generate a socket connection reading thread based on the address data and in combination with a socket function, for processing a connection request from a client;
[0014] The parsing module is used to parse the vsock information received after the connection using the parsing function that modifies the pocl parsing address to obtain a calculation instruction, so that the Pocl daemon program receives the calculation instruction and uses its own resources to process the calculation instruction to obtain a calculation result.
[0015] In a third aspect, an embodiment of the present invention further provides a storage medium comprising computer-executable instructions, which, when executed by a computer processor, are used to perform the OpenCL computation offloading method provided in the above embodiment.
[0016] The OpenCL computation offloading method, device, and storage medium provided by embodiments of the present invention utilize a virtual device creation command to create a virtual vsock transmission device for a virtual machine when the virtual machine boots up. The computing side then initiates the pocld daemon based on the incoming listening address and generates address data for the address cluster. Based on this address data and in conjunction with a socket function, a socket connection read thread is generated to process client connection requests. A parsing function that modifies the pocld parsed address parses the vsock information received after the connection to obtain computation instructions, enabling the pocld daemon to receive the computation instructions and process them using its own resources to obtain computation results. Leveraging the vsock high-speed communication mechanism, the host can achieve high-speed communication with multiple virtual machines, offloading OpenCL computations to devices with computing power. OpenCL offloading can be implemented in cloud computing scenarios. Even in virtual machines without heterogeneous computing devices (GPUs, NPUs, or FPGAs), applications can be accelerated using host-side acceleration devices, just as if they were local devices, without requiring any application modifications. This reduces configuration overhead and enhances security. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Other features, objects and advantages of the present invention will become more apparent upon reading the detailed description of non-limiting embodiments made with reference to the following drawings:
[0018] Figure 11 is a flow chart of the OpenCL calculation offloading method provided in the first embodiment of the present invention;
[0019] Figure 2 1 is a flow chart of the OpenCL calculation offloading method provided in the second embodiment of the present invention;
[0020] Figure 3 1 is a flow chart of the OpenCL calculation offloading method provided in the third embodiment of the present invention;
[0021] Figure 4 Schematic diagram of the structure of the OpenCL calculation offloading device provided in the fourth embodiment of the present invention. DETAILED DESCRIPTION
[0022] The present invention will be further described in detail below with reference to the accompanying drawings and examples. It will be understood that the specific embodiments described herein are intended only to illustrate the present invention and are not intended to limit the present invention. It should also be noted that, for ease of description, the accompanying drawings only illustrate portions relevant to the present invention, not all structures. Example 1
[0023] Figure 1 This is a flowchart of the OpenCL computation offloading method provided in the first embodiment of the present invention. This embodiment is applicable to the case where OpenCL computation offloading is flexibly implemented in cloud computing scenarios. The method can be executed by an OpenCL computation offloading device and specifically includes the following steps:
[0024] Step 110: When the virtual machine starts, a virtual device creation command is used to create a virtual vsock transmission device for the virtual machine.
[0025] In this embodiment, since the vsock communication mechanism needs to be utilized, a corresponding vsock virtual device needs to be set for each virtual machine. For example, a virtual vsock transmission device can be created for the virtual machine through instructions. And it needs to be created before the virtual machine is started so that the corresponding virtual vsock transmission device can be loaded when the virtual machine is started. For example, this can be achieved through the following statement:
[0026] -device vhost-vsock-pci,guest-cid=123, where the address of the virtual machine's vsock transmission device can be set using a statement similar to guest-cid=123.
[0027] In step 120 , the computing side starts the pocld daemon process based on the input listening address and generates address data of the address cluster.
[0028] The aforementioned create command sets the address of the virtual vsock transmission device for the virtual machine and transmits it to the compute side. During the vsock transmission process, this address is used as the listening address. After obtaining this address, the pocld daemon is started. The pocld daemon is a network-based service program that listens on a specific port and receives requests from the virtual machine client through this port. It then uses this port to receive requests from the virtual machine client and forward the virtual machine's OpenCL commands to the compute side for execution.
[0029] The listening address is used to generate address data of the address cluster. Specifically, the address cluster defines the type and format of the address. If it is TCP, the type and format of the IP address are defined, which is represented by AF_INET. In this embodiment, for vsock, it is AF_VSOCK.
[0030] In this embodiment, the computing party is usually a host, but can also be a virtual machine with a computing device, such as a GPU. Therefore, a virtual vsock transmission device needs to be created for the virtual machine corresponding to the computing party.
[0031] Step 130: Based on the address data and in combination with the socket function, a socket connection reading thread is generated to process the connection request of the client.
[0032] Based on the address data obtained in the above steps, the pocld daemon has obtained the AF_VSOCK channel address configuration data. By calling the standard socket, listen, and bind functions, it generates a new thread, readAllClientSocketsThread, which receives and processes client connection requests.
[0033] Step 140: parse the vsock information received after the connection using the parsing function that modifies the pocl parsing address to obtain a calculation instruction, so that the Pocl daemon program receives the calculation instruction and processes the calculation instruction using its own resources to obtain a calculation result.
[0034] After setting up the vsock connection, the OpenCL operation function of the computing party needs to be adjusted to realize the calculation of the calculation content transmitted by vsock. Among them, the parsing function of the pocl address needs to be adaptively adjusted. POCL (Portable Open Computing Language) is an efficient OpenCL standard implementation that provides an easily portable open source implementation. Specifically, the parsing function can be pocl_resolve_address_vosck. Through modification, the pocl daemon program running on the computing party can parse the address format of the vsock_address:port type, directly obtain the corresponding calculation instructions, and then use the program to implement calculation offloading. Exemplarily, the use of the parsing function that modifies the pocl parsing address to parse the vsock information received after the connection to obtain the calculation instruction includes: the computing party uses the vsock connection with the sender to establish a session and returns the session ID to the sender, and uses the session to obtain the vsock information; using the parsing function that modifies the pocl parsing address to parse the vsock information to obtain the calculation instruction. The computing party uses the Pocl daemon program to receive computing instructions and perform the calculations on its computing devices. The computing party's computing devices can be CPUs and / or GPUs. This approach effectively establishes a connection between the computing party and the sending party, allowing computing instructions to be transmitted and results to be returned via a session. Furthermore, using the session approach, the computing party can serve multiple senders and simultaneously receive computing instructions from different senders. Using its own Pocl daemon program, it allocates corresponding computing resources to perform the calculations separately and returns the results. This approach effectively supports cloud computing scenarios.
[0035] When an available computing device is queried, the OpenCL computing instructions in the virtual machine will be quickly transmitted through the newly created send and receive queues on the vsock channel. The virtual machine OpenCL application sends the computing instructions and receives the processing results. The host's Pocl daemon program receives the computing instructions, calculates them through the host computing device, and returns the response to the virtual machine until the application in the guest is completed.
[0036] The OpenCL application in the virtual machine completes all calculations and closes the vsock connection. The pocld daemon program detects the client exit event and releases client resources, completing the entire calculation offload process.
[0037] This embodiment uses a virtual device creation command to create a virtual vsock transmission device for a virtual machine when it boots. The computing side starts the pocld daemon based on the incoming listening address and generates address data for the address cluster. Based on this address data and in conjunction with a socket function, a socket connection read thread is generated to process client connection requests. A parsing function that modifies the pocld parsed address parses the vsock information received after the connection to obtain computation instructions, enabling the pocld daemon to receive the computation instructions and process them using its own resources to obtain the results. Leveraging the vsock high-speed communication mechanism, the host can achieve high-speed communication with multiple virtual machines, offloading OpenCL computations to devices with computing power. OpenCL offloaded computation can be implemented in cloud computing scenarios. Even in virtual machines without heterogeneous computing devices (GPUs, NPUs, or FPGAs), applications can use host-side acceleration devices for acceleration, just as if they were local devices, without requiring any application modifications. This reduces configuration overhead and provides enhanced security.
[0038] In a preferred implementation of this embodiment, the method may further include the following steps: the sender sets the OpenCL driver mode parameters to remote mode and sets the OpenCL remote mode parameters based on the sender's vsock connection parameters; and modifies the address parameter in the pocld library's find_or_create_server function to a vsock parameter. By adjusting to remote mode, the sender, which lacks computing power, can send computing instructions from a local application to an executor for execution. Furthermore, the address parameter in the pocld library's find_or_create_server function is modified to a vsock parameter, specifying that the computing instructions interact with the computing party via the vsock transmission channel. Example 2
[0039] Figure 2 This is a flow chart of the OpenCL computing offloading method provided by the second embodiment of the present invention. This embodiment is optimized based on the above embodiment. The address data is combined with the socket function to generate a socket connection reading thread. The specific optimization is as follows: the bind() function is used to bind the incoming listening address to the socket function; the address data is passed to the connect() function, and the connect() function is used to implement a handshake connection; the listen() function with the address data parameter is used to passively connect to the sender, and the setsocketopt interface parameter is adaptively adjusted for the vsock parameter.
[0040] See also Figure 2, the OpenCL calculation offloading method includes:
[0041] Step 210: When the virtual machine is started, a virtual device creation command is used to create a virtual vsock transmission device for the virtual machine.
[0042] In step 220 , the computing party starts the pocld daemon based on the input listening address and generates address data of the address cluster.
[0043] Step 230: The bind() function binds the input listening address to the socket function.
[0044] In this embodiment, the socket connection read thread is used to process connection requests. Specifically, it processes connection requests from the virtual machine corresponding to the computing requester, thereby establishing a connection between the two. This process uses corresponding functions to accomplish this. Specifically, it first uses the bind() function to bind the incoming address and the corresponding vsock interface to the socket function.
[0045] Step 240: pass the address data into the connect() function, and use the connect() function to implement a handshake connection.
[0046] The function of the connect() function is for the client to actively connect to the server. The connection is established through a three-way handshake, and this connection process is completed by the kernel, not this function. The function of the connect() function is to notify the Linux kernel and let the Linux kernel automatically complete the TCP three-way handshake connection.
[0047] Step 250: Use the listen() function with the address data parameter to passively connect to the sender, and adjust the setsocketopt interface parameter to adapt it to the vsock parameter.
[0048] The main function of the listen() function is to turn the socket (sockfd) into a passive connection listening socket. It can be configured using the setsocketopt interface, for example, using setsocketopt(...) to adjust the parameters to implement support for vsock.
[0049] Step 260: parse the vsock information received after the connection using the parsing function that modifies the pocl parsing address to obtain a calculation instruction, so that the Pocl daemon program receives the calculation instruction and processes the calculation instruction using its own resources to obtain a calculation result.
[0050] This embodiment combines the address data with a socket function to generate a socket connection read thread. Specifically, the optimization involves: using the bind() function to bind the incoming listening address to the socket function; passing the address data to the connect() function, which then implements a handshake connection; using the listen() function with the address data parameter to passively connect to the sender, and adapting the setsocketopt interface parameters to the vsock parameters. The connect function, combined with the incoming address, generates a socket connection read thread, implementing a vsock socket connection, and facilitating the subsequent use of the vsock channel for OpenCL computation offloading. Example 3
[0051] Figure 3 This is a flowchart of the OpenCL computation offloading method provided in Example 3 of the present invention. This example optimizes the above-mentioned example, in which the computation side starts the pocld daemon based on the incoming listening address. Specifically, the optimization involves: enabling the TCP or vsock transmission channel based on the incoming listening address; and starting the corresponding pocld daemon based on the enabled transmission channel. Furthermore, the generation of address cluster address data is optimized to: generate address data for the AF_NET address cluster when starting the pocld daemon for TCP; and generate address data for the AF_VSOCK address cluster when starting the pocld daemon for vsock.
[0052] See also Figure 3 , the OpenCL calculation offloading method includes:
[0053] Step 310: When the virtual machine is started, a virtual device creation command is used to create a virtual vsock transmission device for the virtual machine.
[0054] Step 320: Determine whether to enable a TCP or vsock transmission channel according to the input listening address, and start a corresponding pocld daemon process according to the enabled transmission channel.
[0055] In this embodiment, OpenCL computing offloading can support both tcp and sock connection modes. When the virtual machine is assigned a network card or other communication device, it is more convenient to use the tcp connection setting without making a lot of adjustments. Compared with the tcp mode, the vsock mode not only has better performance, but also has a shorter response time and more secure communication. For example, if you want to use vsock, the command to run the daemon process on the host is pocld -a vsock:2 -p 9999 –vsock; where 2 represents the vsock address and 9999 represents the port; if you use ordinary tcp, pocld -a 192.168.122.1 -p9999;
[0056] 192.168.122.1 is the IP address, and 9999 represents the port number. Depending on the address, either TCP or vsock transport channels are enabled, and the corresponding pocld daemon is started. Accordingly, the client command parameters are adaptively adjusted. For vsock, use POCL_REMOTE0_PARAMETERS='vsock:2:port / 0'. Otherwise, for TCP, use POCL_REMOTE0_PARAMETERS='192.168.122.1:port / 0'.
[0057] Step 330: When the pocld daemon corresponding to tcp is started, address data of the AF_NET address cluster is generated; when the pocld daemon corresponding to vsock is started, address data of the AF_VSOCK address cluster is generated.
[0058] Step 340: Based on the address data and in combination with the socket function, a socket connection reading thread is generated to process the connection request from the client.
[0059] Step 350: parse the vsock information received after the connection using the parsing function that modifies the pocl parsing address to obtain a calculation instruction, so that the Pocl daemon program receives the calculation instruction and processes the calculation instruction using its own resources to obtain a calculation result.
[0060] This embodiment optimizes the computing process by starting the pocld daemon based on the incoming listening address, specifically determining whether to enable the TCP or vsock transmission channel based on the incoming listening address; and starting the corresponding pocld daemon based on the enabled transmission channel. Furthermore, the generation of address cluster address data is optimized to generate address data for the AF_NET address cluster when starting the pocld daemon for TCP, and address data for the AF_VSOCK address cluster when starting the pocld daemon for vsock. This supports both TCP and vsock OpenCL computing offload methods, allowing users to select the appropriate method based on their actual needs.
[0061] In a preferred implementation of this embodiment, the method may further include the following step: using the vsock parameter added to the daemon process to run the daemon process. In the process of implementing the present invention, the inventors discovered the following technical problem: As can be seen from the vsock address disclosed in the above content, it is a 32-bit integer, and the daemon process cannot identify whether it is a domain name address corresponding to TCP or a vsock address. Therefore, the vsock parameter added to the daemon process facilitates the effective identification of whether it is a vsock address or a TCP domain name address when the daemon process is running, preventing it from being parsed as a domain name address. Example 4
[0062] Figure 4 This is a schematic diagram of the structure of the OpenCL calculation offloading device provided by the fourth embodiment of the present invention, see Figure 4 The OpenCL computing offloading device includes:
[0063] A creation module 410 is configured to create a virtual vsock transmission device for the virtual machine using a virtual device creation command when the virtual machine is started;
[0064] The startup module 420 is used to enable the computing party to start the pocld daemon process based on the input listening address and generate address data of the address cluster;
[0065] A combining module 430 is used to generate a socket connection reading thread based on the address data and in combination with a socket function, so as to process a connection request from a client;
[0066] The parsing module 440 is used to parse the vsock information received after the connection using the parsing function that modifies the pocl parsing address to obtain a calculation instruction, so that the Pocl daemon program receives the calculation instruction and uses its own resources to process the calculation instruction to obtain a calculation result.
[0067] The OpenCL computation offloading device provided in this embodiment creates a virtual vsock transmission device for a virtual machine using a virtual device creation command when the virtual machine starts. The computing side starts the pocld daemon based on the incoming listening address and generates address data for the address cluster. Based on this address data and in conjunction with a socket function, a socket connection read thread is generated to process client connection requests. A parsing function that modifies the pocld parsed address parses the vsock information received after the connection to obtain computation instructions, enabling the pocld daemon to receive the computation instructions and process them using its own resources to obtain the computation results. Leveraging the vsock high-speed communication mechanism, the host can achieve high-speed communication with multiple virtual machines, offloading OpenCL computations to devices with computing power. OpenCL offloading can be implemented in cloud computing scenarios. Even in virtual machines without heterogeneous computing devices (GPUs, NPUs, or FPGAs), applications can be accelerated using host-side acceleration devices, just as if they were local devices, without requiring any application modifications. This reduces configuration overhead and provides enhanced security.
[0068] Based on the above embodiments, the device further includes:
[0069] A setting module is used to set the driver mode parameters of OpenCL to remote mode using the sender, and set the remote mode parameters of OpenCL according to the connection parameters of the sender's vsock;
[0070] Modify the module to change the address parameter in the find_or_create_server function of the pocld library to the vsock parameter.
[0071] Based on the above embodiments, the parsing module includes:
[0072] The session establishment unit is used to enable the computing party to establish a session using the vsock connection with the sending party, return the session ID to the sending party, and obtain vsock information using the session;
[0073] The parsing unit is used to parse the vsock information using a parsing function that modifies the pocl parsing address to obtain a calculation instruction.
[0074] Based on the above embodiments, the parsing module includes:
[0075] The computing unit is used to receive computing instructions using the Pocl daemon program and calculate the computing instructions using the computing device of the computing party.
[0076] Based on the above embodiments, the startup module includes:
[0077] A transmission channel determining unit, configured to determine an enabled TCP or vsock transmission channel according to the input listening address;
[0078] The startup unit is used to start the corresponding pocld daemon process according to the enabled transmission channel.
[0079] Based on the above embodiments, the startup module includes:
[0080] The first generating unit is used to generate address data of the AF_NET address cluster when starting the pocld daemon process corresponding to tcp;
[0081] The second generating unit is used to generate address data of the AF_VSOCK address cluster when starting the pocld daemon process corresponding to vsock.
[0082] Based on the above embodiments, the combination module includes:
[0083] The binding unit is used to bind the bind() function to bind the incoming listening address to the socket function;
[0084] An input unit, configured to input the address data into a connect() function, and implement a handshake connection using the connect() function;
[0085] The adjustment unit is used to passively connect to the sender using the listen() function with address data parameters, and to adapt the setsocketopt interface parameters to the vsock parameters.
[0086] Based on the above embodiments, the device further includes:
[0087] The parameter adding unit is used to run the daemon process with the added vsock parameters in the daemon process.
[0088] The OpenCL computation offloading device provided by the embodiment of the present invention can execute the OpenCL computation offloading method provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method. Example 5
[0089] The fifth embodiment of the present invention further provides a storage medium containing computer-executable instructions, which, when executed by a computer processor, are used to perform any of the OpenCL computation offloading methods provided in the above embodiments.
[0090] The computer storage medium of the embodiments of the present invention may adopt any combination of one or more computer-readable media. The computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: an electrical connection having 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 thereof. In this document, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0091] 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 propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. 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.
[0092] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0093] Computer program code for performing the operations of the present invention may be written in one or more programming languages, or a combination thereof, including 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 a remote computer or device. In cases involving a remote computer, 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).
[0094] Note that the above are only preferred embodiments of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments, and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments and may include many other equivalent embodiments without departing from the concept of the present invention. The scope of the present invention is determined by the scope of the appended claims.
Claims
1. An OpenCL calculation offloading method, characterized in that: include: When the virtual machine is started, a virtual vsock transmission device is created for the virtual machine using a virtual device creation command; The computing party starts the pocld daemon based on the incoming listening address and generates the address data of the address cluster; Based on the address data and in combination with the socket function, a socket connection reading thread is generated to process the connection request of the client; The vsock information received after the connection is parsed by using the parsing function that modifies the pocl parsing address to obtain a calculation instruction, so that the Pocl daemon program receives the calculation instruction, processes the calculation instruction using its own resources, and obtains a calculation result.
2. The method according to claim 1, characterized in that: The method further comprises: The sender sets the driver mode parameters of OpenCL to remote mode, and sets the remote mode parameters of OpenCL according to the connection parameters of vsock on the sender side; Change the address parameter in the find_or_create_server function of the pocld library to the vsock parameter.
3. The method according to claim 2, characterized in that The method of using the parsing function of modifying the pocl parsing address to parse the vsock information received after the connection to obtain the calculation instruction includes: The computing party uses the vsock connection with the sending party to establish a session, returns the session ID to the sending party, and uses the session to obtain the vsock information; The vsock information is parsed using a parsing function that modifies the pocl parsing address to obtain a calculation instruction.
4. The method according to claim 3, characterized in that The using the own resources to process the computing instruction includes: The Pocl daemon program is used to receive the computing instruction, and the computing instruction is calculated by the computing device of the computing party.
5. The method according to claim 3, characterized in that: The computing party starts the pocld daemon process based on the incoming listening address, including: Determine to enable TCP or vsock transmission channel according to the incoming listening address; Start the corresponding pocld daemon according to the enabled transmission channel.
6. The method according to claim 5, characterized in that The address data of the generated address cluster includes: When starting the pocld daemon corresponding to TCP, the address data of the AF_NET address cluster is generated; When the pocld daemon corresponding to vsock is started, the address data of the AF_VSOCK address cluster is generated.
7. The method according to claim 1, characterized in that The generating of a read socket connection thread based on the address data and in combination with a socket function comprises: The bind() function binds the incoming listening address to the socket function; The address data is passed into the connect() function, and the connect() function is used to implement a handshake connection; Use the listen() function with the address data parameter to passively connect to the sender, and adjust the setsocketopt interface parameters to adapt to the vsock parameters.
8. The method according to claim 6, characterized in that The method further comprises: Run the daemon with the vsock parameter added to the daemon.
9. An OpenCL computing offloading device, characterized in that: include: A creation module, used to create a virtual vsock transmission device for the virtual machine using a virtual device creation command when the virtual machine is started; The startup module is used to enable the computing party to start the pocld daemon based on the incoming listening address and generate the address data of the address cluster; A combination module, used for generating a read socket connection thread based on the address data and in combination with a socket function, so as to process a connection request from a client; The parsing module is used to parse the vsock information received after the connection by using the parsing function that modifies the pocl parsing address to obtain a calculation instruction, so that the Pocl daemon program receives the calculation instruction, processes the calculation instruction using its own resources, and obtains a calculation result.
10. A storage medium containing computer executable instructions, characterized in that: When the computer executable instructions are executed by a computer processor, they are used to perform the OpenCL computing offloading method according to any one of claims 1 to 8.
