# US 10,120,705 B2 · Method for implementing GPU virtualization and related apparatus, and system

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 10,120,705 B2
- Document ID: US10120705B2
- Status: Granted
- Kind: B2
- Application number: 15/198,819
- Filed: 2016-06-30
- Published: 2016-10-27
- Granted: 2018-11-06
- Earliest claimed: 2013-12-31
- Assignees: Huawei Technologies Co., Ltd.
- Applicants: Huawei Technologies Co., Ltd.
- Inventors: Weidong Han; Yingdong Liu
- Web page: https://patentgrep.com/patent/US10120705B2

## CPC

- G06F 9/45537: {Provision of facilities of other operating environments, e.g. WINE (I/O emulation G06F13/105)}
- G06F 9/4411: {Configuring for operating with peripheral devices; Loading of device drivers}
- G06F 9/45558: {Hypervisor-specific management and integration aspects}
- G06T 1/20: Processor architectures; Processor configuration, e.g. pipelining
- G06F 2009/45579: {I/O management, e.g. providing access to device drivers or storage}
- G06F 2009/45595: {Network integration; Enabling network access in virtual machine instances}
- G06T 2200/28: involving image processing hardware
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)
- G06T: IMAGE DATA PROCESSING OR GENERATION, IN GENERAL

## Abstract

A method for implementing GPU virtualization. The method is applied to a physical host and the physical host includes: a hardware layer including a GPU, a Host running on the hardware layer, and N back-end GPU Domains and M front-end VMs that run on the Host, where there are service channels between the N back-end GPU Domains and the M front-end VMs. The method includes: transferring, by an mth front-end VM, a GPU command to an nth back-end GPU Domain based on the service channels; and processing, by the nth back-end GPU Domain, the GPU command by using a GPU, to obtain corresponding processing result data, where the type of the operating systems running on the nth back-end GPU Domain and the mth front-end VM is same. The invention helps to optimize performance of a GPU virtualization system.

## Claims

### Claim 1

A method for implementing graphics processing unit GPU virtualization, wherein the method is applied to a physical host, wherein the physical host comprises: a hardware layer comprising a GPU, a Host running on the hardware layer, and a host operating system, N back-end GPU Domains and M front-end virtual machines VMs that run on the Host, wherein N is a positive integer greater than or equal to 1, M is a positive integer greater than or equal to 1, M is greater than or equal to N, n is a positive integer that is less than or equal to N, m is a positive integer that is less than or equal to M, and the method comprises:
creating, by the Host OS, the N back-end GPU Domains according to a configured GPU Domain creation policy, wherein the N back-end GPU Domains have operating systems of multiple types, and the GPU Domain creation policy comprises one or more of the following: a quantity of GPU Domains, a quantity of GPUs that are pass-through to the GPU Domain, and types of operating systems of the GPU Domains;
selecting, when the mth front-end VM of the M front-end VMs is started, by the Host OS from the created N back-end GPU Domains according to the type of the operating system of the started mth front-end VM, the nth back-end GPU Domain having the operating system of the corresponding type, wherein there is an association relationship between the mth front-end VM and the nth back-end GPU Domain; and
based on the association relationship between the mth front-end VM and the nth back-end GPU Domain, transferring, by the Host OS, communication information of the corresponding nth back-end GPU Domain to the mth front-end VM, and transferring communication information of the corresponding mth front-end VM to the nth back-end GPU Domain, so that the front-end and back-end service channels are established between the mth front-end VM and the nth back-end GPU Domain;
transferring, by an mth front-end VM, a to-be-transferred GPU command to an nth back-end GPU Domain based on front-end and back-end service channels between the nth back-end GPU Domain of the N back-end GPU Domains and the mth front-end VM of the M front-end VMs, wherein a type of an operating system of the nth back-end GPU Domain is the same as a type of an operating system of the mth front-end VM; and
processing, by the nth back-end GPU Domain, the transferred GPU command by using one or more GPUs, to obtain corresponding processing result data.

### Claim 2 (depends on 1)

The method according to claim 1, wherein the method further comprises:
transferring, by the nth back-end GPU Domain, the corresponding processing result data to the mth front-end VM based on the front-end and back-end service channels between the nth back-end GPU Domain of the N back-end GPU Domains and the ire front-end VM of the M front-end VMs.

### Claim 3 (depends on 1)

The method according to claim 1, wherein if the communication information is a shared memory device identifier, the establishing the front-end and back-end service channels between the mth front-end VM and the nth back-end GPU Domain comprises:
binding event channels between the mth front-end VM and the nth back-end GPU Domain based on the shared memory device identifier of the mth front-end VM and the shared memory device identifier of the nth back-end GPU Domain.

### Claim 4 (depends on 3)

The method according to claim 3, wherein the transferring, by an mth front-end VM, a to-be-transferred GPU command to an nth back-end GPU Domain based on front-end and back-end service channels between the nth back-end GPU Domain of the N back-end GPU Domains and the mth front-end VM of the M front-end VMs comprises:
writing, by the mth front-end VM, the to-be-transferred GPU command to a shared memory between the mth front-end VM and the nth back-end GPU Domain; and
sending, by the mth front-end VM, an mth front-end event notification to the nth back-end GPU Domain through the bound event channels between the mth front-end VM and the nth back-end GPU Domain, wherein the mth front-end event notification is used to represent location information, of the to-be-transferred GPU command, in the shared memory; and
the processing, by the nth back-end GPU Domain, the GPU command by using one or more GPUs, to obtain corresponding processing result data comprises:
reading, by the nth back-end GPU Domain, the GPU command from a corresponding address space of the shared memory between the mth front-end VM and the nth back-end GPU Domain according to the received mth front-end event notification; and
processing, by the nth back-end GPU Domain, the read GPU command by using one or more GPUs that are pass-through to the nth back-end GPU Domain, to obtain the corresponding processing result data.

### Claim 5 (depends on 4)

The method according to claim 4, wherein the method further comprises:
sending, by the nth back-end GPU Domain, an nth back-end event notification to the mth front-end VM through the bound event channels between the mth front-end VM and the nth back-end GPU Domain, wherein the nth back-end event notification is used to represent that data reading is complete; and
releasing, by the mth front-end VM according to the received nth back-end event notification, a memory space that has been occupied by data read by the nth back-end GPU Domain.

### Claim 6 (depends on 4)

The method according to claim 4, wherein the shared memory between the mth front-end VM and the nth back-end GPU Domain comprises: a front-end-to-back-end transmission shared memory and a back-end-to-front-end transmission shared memory, wherein
the writing, by the mth front-end VM, the to-be-transferred GPU command to a shared memory between the mth front-end VM and the nth back-end GPU Domain comprises: writing, by the mth front-end VM, the to-be-transferred GPU command to the front-end-to-back-end transmission shared memory, wherein the mth front-end VM has read and write permissions for the front-end-to-back-end transmission shared memory, and the nth back-end GPU Domain has a read-only permission for the front-end-to-back-end transmission shared memory; and
correspondingly, the reading, by the nth back-end GPU Domain, the GPU command from a corresponding address space of the shared memory according to the received mth front-end event notification comprises: reading, by the nth back-end GPU Domain, the GPU command from a corresponding address space of the front-end-to-back-end transmission shared memory according to the received mth front-end event notification, wherein the mth front-end event notification is used to represent location information, of the to-be-transferred GPU command, in the front-end-to-back-end transmission shared memory;
or,
the writing, by the nth back-end GPU Domain, the to-be-transferred processing result data to the shared memory between the mth front-end VM and the nth back-end GPU Domain comprises: writing, by the nth back-end GPU Domain, the to-be-transferred processing result data to the back-end-to-front-end transmission shared memory, wherein the nth back-end GPU Domain has read and write permissions for the back-end-to-front-end transmission shared memory, and the mth front-end VM has a read-only permission for the back-end-to-front-end transmission shared memory; and
correspondingly, the reading, by the mth front-end VM, the processing result data from the corresponding address space of the shared memory between the mth front-end VM and the nth back-end GPU Domain according to the received back-end event notification comprises: reading, by the mth front-end VM, the processing result data from a corresponding address space of the back-end-to-front-end transmission shared memory according to the received back-end event notification, wherein the nth back-end event notification is used to represent location information, of the to-be-transferred processing result data, in the back-end-to-front-end transmission shared memory.

### Claim 7 (depends on 3)

The method according to claim 3, wherein the transferring, by the nth back-end GPU Domain, the corresponding processing result data to the mth front-end VM based on the front-end and back-end service channels between the nth back-end GPU Domain of the N back-end GPU Domains and the mth front-end VM of the M front-end VMs comprises:
writing, by the nth back-end GPU Domain, the to-be-transferred processing result data to the shared memory between the mth front-end VM and the nth back-end GPU Domain;
sending, by the nth back-end GPU Domain, an nth back-end event notification to the mth front-end VM through the bound event channels between the mth front-end VM and the nth back-end GPU Domain, wherein the nth back-end event notification is used to represent location information, of the to-be-transferred processing result data, in the shared memory; and
reading, by the mth front-end VM, the processing result data from the corresponding address space of the shared memory between the mth front-end VM and the nth back-end GPU Domain according to the received back-end event notification.

### Claim 8 (depends on 7)

The method according to claim 7, wherein the method further comprises:
sending, by the mth front-end VM, the mth front-end event notification to the nth back-end GPU Domain through the bound event channels between the mth front-end VM and the nth back-end GPU Domain, wherein the mth front-end event notification is used to represent that data reading is complete; and
releasing, by the nth back-end GPU Domain according to the received mth front-end event notification, a memory space that has been occupied by data read by the mth front-end VM.

### Claim 9 (depends on 1)

The method according to claim 1, wherein if the communication information is network address information, the establishing the front-end and back-end service channels between the mth front-end VM and the nth back-end GPU Domain comprises:
establishing a network connection between the mth front-end VM and the nth back-end GPU Domain based on the network address information of the mth front-end VM and the network address information of the nth back-end GPU Domain.

### Claim 10 (depends on 9)

The method according to claim 9, wherein the transferring, by an mth front-end VM, a to-be-transferred GPU command to an nth back-end GPU Domain based on front-end and back-end service channels between the nth back-end GPU Domain of the N back-end GPU Domains and the mth front-end VM of the M front-end VMs comprises:
sending, by the mth front-end VM, the to-be-transferred GPU command to the nth back-end GPU Domain over the network connection between the mth front-end VM and the nth back-end GPU Domain.

### Claim 11 (depends on 9)

The method according to claim 9, wherein the transferring, by the nth back-end GPU Domain, the corresponding processing result data to the mth front-end VM based on the front-end and back-end service channels between the nth back-end GPU Domain of the N back-end GPU Domains and the mth front-end VM of the M front-end VMs comprises:
sending, by the nth back-end GPU Domain, the to-be-transferred processing result data to the mth front-end VM over the network connection between the mth front-end VM and the nth back-end GPU Domain.

### Claim 12

A method for implementing graphics processing unit GPU virtualization, wherein the method is applied to a physical host, wherein the physical host comprises: a hardware layer comprising a GPU, a Host running on the hardware layer, and a host operating system, N back-end GPU Domains and M front-end virtual machines VMs that run on the Host, N is a positive integer greater than or equal to 1, M is a positive integer greater than or equal to 1, M is greater than or equal to N, n is a positive integer that is less than or equal to N, m is a positive integer that is less than or equal to M, and the method comprises:
determining, according to an estimated compression time, an estimated decompression time, an estimated compressed-data transmission time, and an estimated non-compression direct-transmission time that are of the GPU command, to compress to-be-transferred GPU command;
compressing, by the mth front-end VM, the to-be-transferred GPU command, and transferring the compressed GPU command to the nth back-end GPU Domain;
determining, by the nth back-end GPU Domain, that the transferred GPU command has been compressed;
decompressing, by the nth back-end GPU Domain, the compressed GPU command, and processing the decompressed GPU command by using one or more GPUs that are pass-through to the nth back-end GPU Domain, to obtain the corresponding processing result data;
determining, according to an estimated compression time, an estimated decompression time, an estimated compressed-data transmission time, and an estimated non-compression direct-transmission time that are of the processing result data, to compress the processing result data; and
compressing, by the nth back-end GPU Domain, the processing result data, and transferring the compressed processing result data to the mth front-end VM.

### Claim 13 (depends on 12)

The method according to claim 12, wherein the determining, according to an estimated compression time, an estimated decompression time, an estimated compressed-data transmission time, and an estimated non-compression direct-transmission time that are of the GPU command or the processing result data, to compress the GPU command or the processing result data comprises:
when a sum of the estimated compression time, the estimated decompression time, and the estimated compressed-data transmission time that are of the GPU command is less than or equal to the estimated non-compression direct-transmission time of the GPU command, determining to compress the GPU command; or,
when a sum of the estimated compression time, the estimated decompression time, and the estimated compressed-data transmission time that are of the GPU command is less than or equal to a sum of the estimated non-compression direct-transmission time of the GPU command and an adjustment value, determining to compress the GPU command; or,
when a sum of the estimated compression time, the estimated decompression time, and the estimated compressed-data transmission time that are of the processing result data is less than or equal to the estimated non-compression direct-transmission time of the processing result data, determining to compress the processing result data; or,
when a sum of the estimated compression time, the estimated decompression time, and the estimated compressed-data transmission time that are of the processing result data is less than or equal to a sum of the estimated non-compression direct-transmission time of the processing result data and an adjustment value, determining to compress the processing result data.

### Claim 14

A physical host, wherein the physical host comprises: a hardware layer comprising a GPU, a Host running on the hardware layer, and Host OS, N back-end GPU Domains and M front-end virtual machines VMs that run on the Host, wherein there are corresponding front-end and back-end service channels between the N back-end GPU Domains and the M front-end VMs, N is a positive integer greater than or equal to 1, M is a positive integer greater than or equal to 1, M is greater than or equal to N, n is a positive integer that is less than or equal to N, and m is a positive integer that is less than or equal to M, wherein
the Host OS is configured to, when the mth front-end VM of the M front-end VMs is started, determine, according to the type of the operating system of the started mth front-end VM, the nth back-end GPU Domain having an operating system of a corresponding type, wherein there is an association relationship between the mth front-end VM and the nth back-end GPU Domain: and
based on the association relationship between the mth front-end VM and the nth back-end GPU Domain, transfer communication information of the corresponding nth back-end GPU Domain to the mth front-end VM, and transfer communication information of the corresponding mth front-end VM to the nth back-end GPU Domain, so that the front-end and back-end service channels are established between the mth front-end VM and the nth back-end GPU Domain;
the mth front-end VM is configured to initiate binding of event channels between the mth front-end VM and the nth back-end GPU Domain based on the shared memory device identifier of the mth front-end VM and the shared memory device identifier of the nth back-end GPU Domain if the communication information is a shared memory device identifier; or
the nth back-end GPU Domain is configured to initiate binding of event channels between the mth front-end VM and the nth back-end GPU Domain based on the shared memory device identifier of the mth front-end VM and the shared memory device identifier of the nth back-end GPU Domain if the communication information is a shared memory device identifier;
the mth front-end VM is further configured to write the to-be-transferred GPU command to a shared memory between the mth front-end VM and the nth back-end GPU Domain; and
send an mth front-end event notification to the nth back-end GPU Domain through the bound event channels between the mth front-end VM and the nth back-end GPU Domain, wherein the mth front-end event notification is used to represent location information, of the to-be-transferred GPU command, in the shared memory;
the nth back-end GPU Domain is further configured to read the GPU command from a corresponding address space of the shared memory between the mth front-end VM and the nth back-end GPU Domain according to the received mth front-end event notification; and process the read GPU command by using one or more GPUs that are pass-through to the nth back-end GPU Domain, to obtain the corresponding processing result data.

### Claim 15 (depends on 14)

The physical host according to claim 14, wherein the nth back-end GPU Domain is further configured to transfer the corresponding processing result data to the mth front-end VM based on the front-end and back-end service channels between the nth back-end GPU Domain of the N back-end GPU Domains and the mth front-end VM of the M front-end VMs.

### Claim 16 (depends on 14)

The physical host according to claim 14, wherein the Host OS is specifically configured to:
create the N back-end GPU Domains according to a configured GPU Domain creation policy, wherein the N back-end GPU Domains have operating systems of multiple types, and the GPU Domain creation policy comprises one or more of the following: a quantity of GPU Domains, a quantity of GPUs that are pass-through to the GPU Domain, and types of operating systems of the GPU Domains;
when the mth front-end VM of the M front-end VMs is started, select, from the N back-end GPU Domains according to the type of the operating system of the started mth front-end VM, the nth back-end GPU Domain having the operating system of the corresponding type, wherein there is the association relationship between the mth front-end VM and the nth back-end GPU Domain; and
based on the association relationship between the mth front-end VM and the nth back-end GPU Domain, transfer the communication information of the corresponding nth back-end GPU Domain to the mth front-end VM, and transfer the communication information of the corresponding mth front-end VM to the nth back-end GPU Domain, so that the front-end and back-end service channels are established between the mth front-end VM and the nth back-end GPU Domain.

### Claim 17 (depends on 14)

The physical host according to claim 14, wherein the Host OS is specifically configured to:
when the mth front-end VM of the M front-end VMs is started, create, by the Host OS according to the type of the operating system of the started mth front-end VM, the nth back-end GPU Domain having the operating system of the corresponding type, wherein there is the association relationship between the mth front-end VM and the nth back-end GPU Domain; and
based on the association relationship between the mth front-end VM and the nth back-end GPU Domain, transfer the communication information of the corresponding nth back-end GPU Domain to the mth front-end VM, and transfer the communication information of the corresponding mth front-end VM to the nth back-end GPU Domain, so that the front-end and back-end service channels are established between the mth front-end VM and the nth back-end GPU Domain.

### Claim 18 (depends on 14)

The physical host according to claim 14, wherein the nth back-end GPU Domain further is configured to send an nth back-end event notification to the mth front-end VM through the bound event channels between the mth front-end VM and the nth back-end GPU Domain, wherein the nth back-end event notification is used to represent that data reading is complete; and
the mth front-end VM is further configured to release, according to the received nth back-end event notification, a memory space that has been occupied by data read by the nth back-end GPU Domain.

### Claim 19 (depends on 14)

The physical host according to claim 14, wherein in the aspect of transferring the corresponding processing result data to the mth front-end VM based on the front-end and back-end service channels between the nth back-end GPU Domain of the N back-end GPU Domains and the mth front-end VM of the M front-end VMs, the nth back-end GPU Domain is specifically configured to write the to-be-transferred processing result data to a shared memory between the mth front-end VM and the nth back-end GPU Domain; and send an nth back-end event notification to the mth front-end VM through the bound event channels between the mth front-end VM and the nth back-end GPU Domain, wherein the nth back-end event notification is used to represent location information, of the to-be-transferred processing result data, in the shared memory between the mth front-end VM and the nth back-end GPU Domain; and
the mth front-end VM is further configured to read the processing result data from a corresponding address space of the shared memory between the mth front-end VM and the nth back-end GPU Domain according to the received nth back-end event notification.

### Claim 20 (depends on 19)

The physical host according to claim 19, wherein the mth front-end VM is further configured to send the mth front-end event notification to the nth back-end GPU Domain through the bound event channels between the mth front-end VM and the nth back-end GPU Domain, wherein the mth front-end event notification is used to represent that data reading is complete; and
the nth back-end GPU Domain is further configured to release, according to the received mth front-end event notification, a memory space that has been occupied by data read by the mth front-end VM.

### Claim 21 (depends on 14)

The physical host according to claim 14, wherein the shared memory between the mth front-end VM and the nth back-end GPU Domain comprises a front-end-to-back-end transmission shared memory and a back-end-to-front-end transmission shared memory, wherein
in the aspect of writing, by the mth front-end VM, the to-be-transferred GPU command to the shared memory between the mth front-end VM and the nth back-end GPU Domain, the mth front-end VM is specifically configured to write the to-be-transferred GPU command to the front-end-to-back-end transmission shared memory, wherein the mth front-end VM has read and write permissions for the front-end-to-back-end transmission shared memory, and the nth back-end GPU Domain has a read-only permission for the front-end-to-back-end transmission shared memory; and
correspondingly, in the aspect of reading the GPU command from the corresponding address space of the shared memory between the mth front-end VM and the nth back-end GPU Domain according to the received mth front-end event notification, the nth back-end GPU Domain is specifically configured to read the GPU command from a corresponding address space of the front-end-to-back-end transmission shared memory according to the received mth front-end event notification, wherein the mth front-end event notification is used to represent location information, of the to-be-transferred GPU command, in the front-end-to-back-end transmission shared memory;
or,
in the aspect of writing the to-be-transferred processing result data to the shared memory between the mth front-end VM and the nth back-end GPU Domain, the nth back-end GPU Domain is specifically configured to write the to-be-transferred processing result data to the back-end-to-front-end transmission shared memory, wherein the nth back-end GPU Domain has read and write permissions for the back-end-to-front-end transmission shared memory, and the mth front-end VM has a read-only permission for the back-end-to-front-end transmission shared memory; and
correspondingly, in the aspect of reading the processing result data from the corresponding address space of the shared memory between the mth front-end VM and the nth back-end GPU Domain according to the received nth back-end event notification, the mth front-end VM is specifically configured to read the processing result data from a corresponding address space of the back-end-to-front-end transmission shared memory according to the received nth back-end event notification, wherein the nth back-end event notification is used to represent location information, of the to-be-transferred processing result data, in the back-end-to-front-end transmission shared memory.

### Claim 22

A physical host, wherein the physical host comprises: a hardware layer comprising a GPU, a Host running on the hardware layer, and Host OS, N back-end GPU Domains and M front-end virtual machines VMs that run on the Host, wherein there are corresponding front-end and back-end service channels between the N back-end GPU Domains and the M front-end VMs, N is a positive integer greater than or equal to 1, M is a positive integer greater than or equal to 1, M is greater than or equal to N, n is a positive integer that is less than or equal to N, and m is a positive integer that is less than or equal to M, wherein
the mth front-end VM is further configured to determine, according to an estimated compression time, an estimated decompression time, an estimated compressed-data transmission time, and an estimated non-compression direct-transmission time that are of the GPU command, to compress the GPU command; andcompress the to-be-transferred GPU command, and transfer the compressed GPU command to the nth back-end GPU Domain;
the nth back-end GPU Domain is configured to determine that the transferred GPU command has been compressed; and decompress the compressed GPU command, and process the decompressed GPU command by using one or more GPUs that are pass-through to the nth back-end GPU Domain, to obtain the corresponding processing result data.
the nth back-end GPU Domain is further configured to determine, according to an estimated compression time, an estimated decompression time, an estimated compressed-data transmission time, and an estimated non-compression direct-transmission time that are of the processing result data, to compress the processing result data; and
compress the processing result data, and transfer the compressed processing result data to the mth front-end VM.

### Claim 23 (depends on 22)

The physical host according to claim 22, wherein in the aspect of determining, according to the estimated compression time, the estimated decompression time, the estimated compressed-data transmission time, and the estimated non-compression direct-transmission time that are of the GPU command, to compress the GPU command, the mth front-end VM is specifically configured to: when a sum of the estimated compression time, the estimated decompression time, and the estimated compressed-data transmission time that are of the GPU command is less than or equal to the estimated non-compression direct-transmission time of the GPU command, determine to compress the GPU command; or, when a sum of the estimated compression time, the estimated decompression time, and the estimated compressed-data transmission time that are of the GPU command is less than or equal to a sum of the estimated non-compression direct-transmission time of the GPU command and an adjustment value, determine to compress the GPU command;
or,
in the aspect of determining, according to the estimated compression time, the estimated decompression time, the estimated compressed-data transmission time, and t estimated non-compression direct-transmission time that are of the processing result data, to compress the processing result data, the nth back-end GPU Domain is specifically configured to: when a sum of the estimated compression time, the estimated decompression time, and the estimated compressed-data transmission time that are of the processing result data is less than or equal to the estimated non-compression direct-transmission time of the processing result data, determine to compress the processing result data; or, when a sum of the estimated compression time, the estimated decompression time, and the estimated compressed-data transmission time that are of the processing result data is less than or equal to a sum of the estimated non-compression direct-transmission time of the processing result data and an adjustment value, determine to compress the processing result data.

### Claim 24

A method for implementing graphics processing unit GPU virtualization, wherein the method comprises:
transferring a GPU command to be transferred by an mth front-end VM, to an nth back-end GPU Domain based on front-end and back-end service channels between the nth back-end GPU Domain of N back-end graphics processing unit domains GPU Domains in a physical host and the mth front-end VM of M front-end virtual machines VMs in the physical host, wherein a type of an operating system of the nth back-end GPU Domain is the same as a type of an operating system of the mth front-end VM, N is a positive integer greater than or equal to 1, M is a positive integer greater than or equal to 1, M is greater than or equal to N, n is a positive integer that is less than or equal to N, and m is a positive integer that is less than or equal to M; and
processing, by using one or more GPUs in the physical host, the GPU command obtained by the nth back-end GPU Domain, to obtain corresponding processing result data;
wherein the front-end and back-end service channels between the nth back-end GPU Domain of the N back-end GPU Domains and the mth front-end VM of the M front-end VMs are established by using a following method:
determining, when the mth front-end VM of the M front-end VMs is started, according to the type of the operating system of the started mth front-end VM, the nth back-end GPU Domain having an operating system of a corresponding type, wherein there is an association relationship between the mth front-end VM and the nth back-end GPU Domain; and
based on the association relationship between the mth front-end VM and the nth back-end GPU Domain, transferring communication information of the corresponding nth back-end GPU Domain to the mth front-end VM, and transferring communication information of the corresponding mth front-end VM to the nth back-end GPU Domain, so that the front-end and back-end service channels are established between the mth front-end VM and the nth back-end GPU Domain;
wherein if the communication information is a shared memory device identifier, the establishing the front-end and back-end service channels between the mth front-end VM and the nth back-end GPU Domain comprises:
binding event channels between the mth front-end VM and the nth back-end GPU Domain based on the shared memory device identifier of the mth front-end VM and the shared memory device identifier of the nth back-end GPU Domain;
wherein the transferring a GPU command to be transferred by an mth front-end VM, to an nth back-end GPU Domain based on front-end and back-end service channels between the nth back-end GPU Domain of N back-end GPU Domains and the mth front-end VM of M front-end VMs comprises:
writing, to a shared memory between the mth front-end VM and the nth back-end GPU Domain, the GPU command to be transferred by the mth front-end VM; and
sending an mth front-end event notification of the mth front-end VM to the nth back-end GPU Domain through the bound event channels between the mth front-end VM and the nth back-end GPU Domain, wherein the mth front-end event notification is used to represent location information, of the to-be-transferred GPU command, in the shared memory; and
the processing, by using one or more GPUs in the physical host, the GPU command obtained by the nth back-end GPU Domain, to obtain corresponding processing result data comprises:
reading the GPU command from a corresponding address space of the shared memory between the mth front-end VM and the nth back-end GPU Domain according to the mth front-end event notification received by the nth back-end GPU Domain; and
processing the read GPU command by using one or more GPUs in the physical host that are pass-through to the nth back-end GPU Domain, to obtain the corresponding processing result data.

### Claim 25 (depends on 24)

The method according to claim 24, wherein the method further comprises:
transferring the corresponding processing result data from the nth back-end GPU Domain to the mth front-end VM based on the front-end and back-end service channels between the nth back-end GPU Domain of the N back-end GPU Domains and the mth front-end VM of the M front-end VMs.

### Claim 26 (depends on 24)

The method according to claim 24, wherein the method further comprises:
sending an nth back-end event notification of the nth back-end GPU Domain to the mth front-end VM through the bound event channels between the mth front-end VM and the nth back-end GPU Domain, wherein the nth back-end event notification is used to represent that data reading is complete; and
releasing, according to the nth back-end event notification received by the mth front-end VM, a memory space that has been occupied by data read by the nth back-end GPU Domain.

### Claim 27 (depends on 24)

The method according to claim 24, wherein the transferring the corresponding processing result data from the nth back-end GPU Domain to the mth front-end VM based on the front-end and back-end service channels between the nth back-end GPU Domain of the N back-end GPU Domains and the mth front-end VM of the M front-end VMs comprises:
writing, to a shared memory between the mth front-end VM and the nth back-end GPU Domain, the processing result data to be transferred by the nth back-end GPU Domain;
sending an nth back-end event notification of the nth back-end GPU Domain to the mth front-end VM through the bound event channels between the mth front-end VM and the nth back-end GPU Domain, wherein the nth back-end event notification is used to represent location information, of the to-be-transferred processing result data, in the shared memory; and
reading the processing result data from the corresponding address space of the shared memory between the mth front-end VM and the nth back-end GPU Domain according to the nth back-end event notification received by the mth front-end VM.

### Claim 28 (depends on 27)

The method according to claim 27, wherein the method further comprises:
sending the mth front-end event notification of the mth front-end VM to the nth back-end GPU Domain through the bound event channels between the mth front-end VM and the nth back-end GPU Domain, wherein the mth front-end event notification is used to represent that data reading is complete; and
releasing, according to the mth front-end event notification received by the nth back-end GPU Domain, a memory space that has been occupied by data read by the mth front-end VM.

### Claim 29 (depends on 24)

The method according to claim 24, wherein the shared memory between the mth front-end VM and the nth back-end GPU Domain comprises: a front-end-to-back-end transmission shared memory and a back-end-to-front-end transmission shared memory,
the writing, to a shared memory between the mth front-end VM and the nth back-end GPU Domain, the GPU command to be transferred by the mth front-end VM comprises: writing, to the front-end-to-back-end transmission shared memory, the GPU command to be transferred by the mth front-end VM, wherein the mth front-end VM has read and write permissions for the front-end-to-back-end transmission shared memory, and the nth back-end GPU Domain has a read-only permission for the front-end-to-back-end transmission shared memory; and
correspondingly, the reading the GPU command from a corresponding address space of the shared memory according to the mth front-end event notification received by the nth back-end GPU Domain comprises: read the GPU command from a corresponding address space of the front-end-to-back-end transmission shared memory according to the mth front-end event notification received by the nth back-end GPU Domain, wherein the mth front-end event notification is used to represent location information, of the to-be-transferred GPU command, in the front-end-to-back-end transmission shared memory;
or,
the writing, to a shared memory between the mth front-end VM and the nth back-end GPU Domain, the processing result data to be transferred by the nth back-end GPU Domain comprises: writing, to the back-end-to-front-end transmission shared memory, the processing result data to be transferred by the nth back-end GPU Domain, wherein the nth back-end GPU Domain has read and write permissions for the back-end-to-front-end transmission shared memory, and the mth front-end VM has a read-only permission for the back-end-to-front-end transmission shared memory; and
correspondingly, the reading the processing result data from the corresponding address space of the shared memory between the mth front-end VM and the nth back-end GPU Domain according to the nth back-end event notification received by the mth front-end VM comprises: reading the processing result data from a corresponding address space of the back-end-to-front-end transmission shared memory according to the nth back-end event notification received by the mth front-end VM, wherein the nth back-end event notification is used to represent location information, of the to-be-transferred processing result data, in the back-end-to-front-end transmission shared memory.

### Claim 30

A method for implementing graphics processing unit GPU virtualization, wherein the method comprises:
transferring a GPU command to be transferred by an mth front-end VM, to an nth back-end GPU Domain based on front-end and back-end service channels between the nth back-end GPU Domain of N back-end graphics processing unit domains GPU Domains in a physical host and the mth front-end VM of M front-end virtual machines VMs in the physical host, wherein a type of an operating system of the nth back-end GPU Domain is the same as a type of an operating system of the mth front-end VM, N is a positive integer greater than or equal to 1, M is a positive integer greater than or equal to 1, M is greater than or equal to N, n is a positive integer that is less than or equal to N, and m is a positive integer that is less than or equal to M; and
processing, by using one or more GPUs in the physical host, the GPU command obtained by the nth back-end GPU Domain, to obtain corresponding processing result data;
wherein the method further comprises: determining, according to an estimated compression time, an estimated decompression time, an estimated compressed-data transmission time, and an estimated non-compression direct-transmission time that are of the GPU command, to compress the GPU command;
the transferring a GPU command to be transferred by an mth front-end VM, to an nth back-end GPU Domain comprises: compressing the GPU command to be transferred by the mth front-end VM, and transferring the compressed GPU command to the nth back-end GPU Domain;
the method further comprises: determining that the GPU command transferred to the nth back-end GPU Domain has been compressed; and
the processing, by using one or more GPUs in the physical host, the GPU command transferred to the nth back-end GPU Domain, to obtain the corresponding processing result data comprises: decompressing the compressed GPU command transferred to the nth back-end GPU Domain, and processing the decompressed GPU command by using one or more GPUs in the physical host that are pass-through to the nth back-end GPU Domain, to obtain the corresponding processing result data;
determining, according to an estimated compression time, an estimated decompression time, an estimated compressed-data transmission time, and an estimated non-compression direct-transmission time that are of the processing result data, to compress the processing result data; and
the transferring the processing result data to be transferred by the nth back-end GPU Domain, to the mth front-end VM comprises: compressing the processing result data to be transferred by the nth back-end GPU Domain, and transferring the compressed processing result data to the mth front-end VM.
