WO2018119951A1 - Gpu virtualization method, device, system, and electronic apparatus, and computer program product - Google Patents

Gpu virtualization method, device, system, and electronic apparatus, and computer program product Download PDF

Info

Publication number
WO2018119951A1
WO2018119951A1 PCT/CN2016/113260 CN2016113260W WO2018119951A1 WO 2018119951 A1 WO2018119951 A1 WO 2018119951A1 CN 2016113260 W CN2016113260 W CN 2016113260W WO 2018119951 A1 WO2018119951 A1 WO 2018119951A1
Authority
WO
WIPO (PCT)
Prior art keywords
graphics processing
operating system
shared memory
processing instruction
memory
Prior art date
Application number
PCT/CN2016/113260
Other languages
French (fr)
Chinese (zh)
Inventor
温燕飞
Original Assignee
深圳前海达闼云端智能科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳前海达闼云端智能科技有限公司 filed Critical 深圳前海达闼云端智能科技有限公司
Priority to CN201680002845.1A priority Critical patent/CN107003892B/en
Priority to PCT/CN2016/113260 priority patent/WO2018119951A1/en
Publication of WO2018119951A1 publication Critical patent/WO2018119951A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45554Instruction set architectures of guest OS and hypervisor or native processor differ, e.g. Bochs or VirtualPC on PowerPC MacOS
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • G06F9/45533Hypervisors; Virtual machine monitors
    • G06F9/45558Hypervisor-specific management and integration aspects
    • G06F2009/45583Memory management, e.g. access or allocation

Abstract

A GPU virtualization method, device, system, and electronic apparatus, and computer program product. The method comprises: receiving an image processing operation at a first operating system (201), and determining, according to the image processing operation, a corresponding image processing instruction; and transmitting, by means of a shared memory (203), to a second operating system (202) the image processing instruction, wherein the shared memory (203) is readable and writable for the first operating system (201) and the second operating system (202). The above method of the present invention can be employed to virtualize a GPU.

Description

GPU虚拟化方法、装置、系统及电子设备、计算机程序产品GPU virtualization method, device, system and electronic device, computer program product 技术领域Technical field
本申请涉及计算机技术,具体地,涉及一种图形处理器GPU的虚拟化方法、装置、系统及电子设备、计算机程序产品。The present application relates to computer technology, and in particular, to a virtualization method, device, system, electronic device, and computer program product of a graphics processor GPU.
背景技术Background technique
图1中示出了基于Qemu/KVM(Kernel-based Virtual Machine,基于内核的虚拟机)技术的虚拟化架构。A virtualization architecture based on Qemu/KVM (Kernel-based Virtual Machine) technology is shown in FIG.
如图1所示,基于Qemu/KVM技术的虚拟化架构由一个主Host操作系统,若干个虚拟出来的客Guest操作系统组成。Host操作系统包括多个Host用户空间程序、Host Linux内核。每个客Guest操作系统分别包括用户空间、Guest Linux内核、和Qemu。这些操作系统运行在同一套硬件处理器芯片上,共享处理器及外设资源。支持虚拟化架构的ARM处理器至少包含EL2,EL1,EL0三种模式,EL2模式下运行虚拟机管理器Hypervisor程序;EL1模式下运行Linux内核程序,即,Linux kernel程序;EL0模式下运行用户空间程序。Hypervisor层管理CPU、内存、定时器、中断等硬件资源,并通过CPU、内存、定时器、中断的虚拟化资源,可以把不同的操作系统分时加载到物理处理器上运行,从而实现系统虚拟化的功能。As shown in Figure 1, the virtualization architecture based on Qemu/KVM technology consists of a primary Host operating system and several virtual guest guest operating systems. The Host operating system includes multiple Host user space programs and the Host Linux kernel. Each guest guest operating system includes user space, Guest Linux kernel, and Qemu. These operating systems run on the same set of hardware processor chips, sharing processor and peripheral resources. The ARM processor supporting the virtualization architecture includes at least EL2, EL1, and EL0 modes, and the virtual machine manager Hypervisor program is run in EL2 mode; the Linux kernel program is run in EL1 mode, that is, the Linux kernel program; and the user space is run in the EL0 mode. program. The Hypervisor layer manages hardware resources such as CPU, memory, timers, and interrupts, and can use different CPUs, memory, timers, and interrupted virtualization resources to load different operating systems into physical processors for runtime. Functionality.
KVM/Hypervisor跨越Host Linux kernel和Hypervisor两层,一方面为模拟处理器Qemu提供驱动节点,即,允许Qemu通过KVM节点创建虚拟CPU,并管理虚拟化资源;另一方面KVM/Hypervisor还可以把Host Linux系统从物理CPU上切换出去,然后把Guest Linux系统加载到物理处理器上运行,并处理Guest Linux系统异常退出的后续事务。 KVM/Hypervisor spans the Host Linux kernel and Hypervisor. It provides a driver node for the analog processor Qemu, which allows Qemu to create virtual CPUs through KVM nodes and manage virtualized resources. On the other hand, KVM/Hypervisor can also host Host. The Linux system switches out from the physical CPU, then loads the Guest Linux system onto the physical processor and processes the subsequent transactions that the Guest Linux system exits abnormally.
Qemu作为Host Linux的一个应用运行,为Guest Linux的运行提供虚拟的硬件设备资源,通过KVM/Hypervisor模块的设备KVM节点,创建虚拟CPU,分配物理硬件资源,实现把一个未经修改的Guest Linux加载到物理硬件处理上去运行。As an application running on Host Linux, Qemu provides virtual hardware device resources for the operation of Guest Linux. Through the KVM node of the KVM/Hypervisor module, a virtual CPU is created, and physical hardware resources are allocated to load an unmodified Guest Linux. Go to the physical hardware processing to run.
在手机或平板等终端设备上实现上述虚拟化架构,需要解决所有硬件设备的虚拟化,允许虚拟出来的操作系统也能使用真实的硬件设备。目前还没有图形处理器GPU(Graphics Processing Unit,图形处理器)的虚拟化方法。To implement the above virtualization architecture on a terminal device such as a mobile phone or a tablet, it is necessary to solve the virtualization of all hardware devices, and the virtual operating system can also use real hardware devices. There is currently no virtualization method for the graphics processing unit GPU (Graphics Processing Unit).
发明内容Summary of the invention
本申请实施例中提供了一种GPU虚拟化方法、装置、系统及电子设备、计算机程序产品,用于实现GPU的虚拟化。In the embodiment of the present application, a GPU virtualization method, device, system, and electronic device and computer program product are provided for implementing virtualization of a GPU.
根据本申请实施例的第一个方面,提供了一种图形处理器GPU的虚拟化方法,包括:接收在第一操作系统处的图形处理操作,并根据该图形处理操作确定对应的图形处理指令;将该图形处理指令通过共享内存传递至第二操作系统;其中,该共享内存对该第一操作系统和该第二操作系统均处于可读和可写状态。According to a first aspect of the embodiments of the present application, a virtualization method of a graphics processor GPU is provided, including: receiving a graphics processing operation at a first operating system, and determining a corresponding graphics processing instruction according to the graphics processing operation Passing the graphics processing instruction to the second operating system through the shared memory; wherein the shared memory is in a readable and writable state for both the first operating system and the second operating system.
根据本申请实施例的第二个方面,提供了一种GPU的虚拟化方法,包括:通过共享内存获取来自第一操作系统的图形处理指令;在第二操作系统处执行该图形处理指令,得到处理结果,并将处理结果作为图形处理操作的响应进行显示,其中,该图形处理操作是在第一操作系统处接收到的;其中,该共享内存对该第一操作系统和该第二操作系统均处于可读和可写状态。According to a second aspect of the embodiments of the present application, a virtualization method of a GPU is provided, including: acquiring a graphics processing instruction from a first operating system by using a shared memory; and executing the graphics processing instruction at a second operating system to obtain Processing the result, and displaying the processing result as a response to the graphics processing operation, wherein the graphics processing operation is received at the first operating system; wherein the shared memory is for the first operating system and the second operating system Both are readable and writable.
根据本申请实施例的第三个方面,提供了一种GPU的虚拟化装置,包括:第一接收模块,用于接收在第一操作系统处的图形处理操作,并根据该图形处理操作确定对应的图形操作指令;第一传递模块,用于将该图形处理指令通过共享内存传递至该第二操作系统;其中,该共享内存对该第一操作系统和第二操作系统均处于可读和可写状态。 According to a third aspect of the embodiments of the present application, a GPU virtualization apparatus includes: a first receiving module, configured to receive a graphics processing operation at a first operating system, and determine a corresponding according to the graphics processing operation a graphics operation instruction; a first delivery module, configured to pass the graphics processing instruction to the second operating system through the shared memory; wherein the shared memory is readable and readable by the first operating system and the second operating system Write status.
根据本申请实施例的第四个方面,提供了一种GPU的虚拟化装置,包括:获取模块,用于通过共享内存获取来自第一操作系统的图形处理指令;执行模块,用于在该第二操作系统处执行该图形处理指令,得到处理结果,并将处理结果作为图形处理操作的响应进行显示,其中,该图形处理操作是在第一操作系统处接收到的;其中,该共享内存对该第一操作系统和第二操作系统均处于可读和可写状态。According to a fourth aspect of the embodiments of the present application, a virtualization device of a GPU is provided, including: an obtaining module, configured to acquire a graphics processing instruction from a first operating system by using a shared memory; and an execution module, in the Executing, by the operating system, the graphics processing instruction, obtaining a processing result, and displaying the processing result as a response of the graphics processing operation, where the graphics processing operation is received at the first operating system; wherein the shared memory pair The first operating system and the second operating system are both readable and writable.
根据本申请实施例的第五个方面,提供了一种GPU的虚拟化系统,包括:第一操作系统,包括如本申请实施例第三个方面的GPU的虚拟化装置;共享内存,用于存储来自该第一操作系统的图形操作指令和来自第二操作系统的处理结果;其中,该共享内存对该第一操作系统和第二操作系统均处于可读和可写状态;第二操作系统,包括如本申请实施例第四个方面的GPU的虚拟化装置。According to a fifth aspect of the embodiments of the present application, a virtualization system of a GPU is provided, including: a first operating system, including a virtualization device of a GPU according to the third aspect of the embodiment of the present application; a shared memory, configured to: Storing graphics operation instructions from the first operating system and processing results from the second operating system; wherein the shared memory is in a readable and writable state for both the first operating system and the second operating system; A virtualization device for a GPU, such as the fourth aspect of the embodiments of the present application.
根据本申请实施例的第六个方面,提供了一种电子设备,该电子设备包括:显示器,存储器,一个或多个处理器;以及一个或多个模块,该一个或多个模块被存储在该存储器中,并被配置成由该一个或多个处理器执行,该一个或多个模块包括用于执行本申请实施例第一个方面的GPU的虚拟化方法中各个步骤的指令。According to a sixth aspect of embodiments of the present application, there is provided an electronic device comprising: a display, a memory, one or more processors; and one or more modules, the one or more modules being stored In the memory, and configured to be executed by the one or more processors, the one or more modules include instructions for performing the various steps in the virtualization method of the GPU of the first aspect of the embodiments of the present application.
根据本申请实施例的第七个方面,提供了一种电子设备,该电子设备包括:显示器,存储器,一个或多个处理器;以及一个或多个模块,该一个或多个模块被存储在该存储器中,并被配置成由该一个或多个处理器执行,该一个或多个模块包括用于执行本申请实施例第二个方面的GPU的虚拟化方法中各个步骤的指令。According to a seventh aspect of embodiments of the present application, there is provided an electronic device comprising: a display, a memory, one or more processors; and one or more modules, the one or more modules being stored In the memory, and configured to be executed by the one or more processors, the one or more modules include instructions for performing the various steps in the virtualization method of the GPU of the second aspect of the embodiments of the present application.
根据本申请实施例的第八个方面,提供了一种与包括显示器的电子设备结合使用的计算机程序产品,该计算机程序产品包括计算机可读的存储介质和内嵌于其中的计算机程序机制,该计算机程序机制包括用于执行本申请实施例第一个方面的GPU的虚拟化方法中各个步骤的指令。 According to an eighth aspect of embodiments of the present application, there is provided a computer program product for use in conjunction with an electronic device including a display, the computer program product comprising a computer readable storage medium and a computer program mechanism embedded therein The computer program mechanism includes instructions for performing the various steps in the virtualization method of the GPU of the first aspect of the embodiments of the present application.
根据本申请实施例的第九个方面,提供了一种与包括显示器的电子设备结合使用的计算机程序产品,该计算机程序产品包括计算机可读的存储介质和内嵌于其中的计算机程序机制,该计算机程序机制包括用于执行本申请实施例第二个方面的GPU的虚拟化方法各个步骤的指令。According to a ninth aspect of embodiments of the present application, there is provided a computer program product for use in conjunction with an electronic device including a display, the computer program product comprising a computer readable storage medium and a computer program mechanism embedded therein The computer program mechanism includes instructions for performing the various steps of the virtualization method of the GPU of the second aspect of the embodiments of the present application.
采用根据本申请实施例的GPU虚拟化方法、装置、系统及电子设备、计算机程序产品,通过第一操作系统和第二操作系统之间的共享内存实现图形处理指令和执行结果的传递,实现了GPU的虚拟化。The GPU virtualization method, device, system, and electronic device and computer program product according to the embodiments of the present application are implemented, and the graphics processing instruction and the execution result are transmitted through the shared memory between the first operating system and the second operating system. Virtualization of the GPU.
附图说明DRAWINGS
此处所说明的附图用来提供对本申请的进一步理解,构成本申请的一部分,本申请的示意性实施例及其说明用于解释本申请,并不构成对本申请的不当限定。在附图中:The drawings described herein are intended to provide a further understanding of the present application, and are intended to be a part of this application. In the drawing:
图1中示出了基于Qemu/KVM技术的虚拟化架构示意图;A schematic diagram of a virtualization architecture based on Qemu/KVM technology is shown in FIG. 1;
图2示出了用于实施本申请实施例中GPU的虚拟化方法的一种系统架构示意图;2 is a schematic diagram of a system architecture for implementing a virtualization method of a GPU in an embodiment of the present application;
图3示出了根据本申请实施例一的GPU的虚拟化方法的流程图;FIG. 3 is a flowchart of a virtualization method of a GPU according to Embodiment 1 of the present application;
图4示出了根据本申请实施例二的GPU的虚拟化方法的流程图;FIG. 4 is a flowchart of a virtualization method of a GPU according to Embodiment 2 of the present application;
图5示出了根据本申请实施例三的GPU的虚拟化方法的流程图;FIG. 5 is a flowchart of a virtualization method of a GPU according to Embodiment 3 of the present application;
图6示出了根据本申请实施例四的GPU的虚拟化装置的结构示意图;FIG. 6 is a schematic structural diagram of a virtualization device of a GPU according to Embodiment 4 of the present application;
图7示出了根据本申请实施例五的GPU的虚拟化装置的结构示意图;FIG. 7 is a schematic structural diagram of a virtualization device of a GPU according to Embodiment 5 of the present application;
图8示出了根据本申请实施例六的GPU的虚拟化系统的结构示意图;FIG. 8 is a schematic structural diagram of a virtualization system of a GPU according to Embodiment 6 of the present application;
图9示出了根据本申请实施例七的电子设备的结构示意图;FIG. 9 is a schematic structural diagram of an electronic device according to Embodiment 7 of the present application;
图10示出了根据本申请实施例八的电子设备的结构示意图。FIG. 10 is a schematic structural diagram of an electronic device according to Embodiment 8 of the present application.
具体实施方式detailed description
在实现本申请的过程中,发明人发现,在手机或平板等终端设备上实现上述虚拟化架构,需要解决所有硬件设备的虚拟化,允许虚拟出来的操作系 统也能使用真实的硬件设备。因此,需要提供一种GPU的虚拟化方法。In the process of implementing the present application, the inventor has found that implementing the above virtualization architecture on a terminal device such as a mobile phone or a tablet requires solving the virtualization of all hardware devices and allowing the virtual operating system to be operated. The system can also use real hardware devices. Therefore, there is a need to provide a virtualization method for a GPU.
针对上述问题,本申请实施例中提供了一种GPU虚拟化方法、装置、系统及电子设备、计算机程序产品,通过第一操作系统和第二操作系统之间的共享内存实现图形处理指令和执行结果的传递,实现了GPU的虚拟化。In the embodiment of the present application, a GPU virtualization method, apparatus, system, electronic device, and computer program product are provided, and graphics processing instructions and execution are implemented by using a shared memory between the first operating system and the second operating system. The delivery of the results enables virtualization of the GPU.
本申请实施例中的方案可以应用于各种场景中,例如,采用基于Qemu/KVM技术的虚拟化架构的智能终端、安卓模拟器等。The solution in the embodiment of the present application can be applied to various scenarios, for example, a smart terminal based on a virtualization architecture based on Qemu/KVM technology, an Android emulator, and the like.
本申请实施例中的方案可以采用各种计算机语言实现,例如,面向对象的程序设计语言Java等。The solution in the embodiment of the present application can be implemented in various computer languages, for example, an object-oriented programming language Java or the like.
为了使本申请实施例中的技术方案及优点更加清楚明白,以下结合附图对本申请的示例性实施例进行进一步详细的说明,显然,所描述的实施例仅是本申请的一部分实施例,而不是所有实施例的穷举。需要说明的是,在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互组合。The exemplary embodiments of the present application are further described in detail below with reference to the accompanying drawings. Not all embodiments are exhaustive. It should be noted that the embodiments in the present application and the features in the embodiments may be combined with each other without conflict.
实施例一Embodiment 1
图2示出了用于实施本申请实施例中GPU的虚拟化方法的一种系统架构。如图2所示,根据本申请实施例的GPU虚拟化系统包括第一操作系统201、第二操作系统202和共享内存203。具体地,该第一操作系统可以是Guest操作系统;该第二操作系统可以是Host操作系统。应当理解,在具体实施时,该第一操作系统也可以是Host操作系统,该第二操作也可以是Guest操作系统,本申请对此不作限制。FIG. 2 shows a system architecture for implementing a virtualization method of a GPU in an embodiment of the present application. As shown in FIG. 2, the GPU virtualization system according to an embodiment of the present application includes a first operating system 201, a second operating system 202, and a shared memory 203. Specifically, the first operating system may be a guest operating system; the second operating system may be a Host operating system. It should be understood that, in a specific implementation, the first operating system may also be a Host operating system, and the second operation may also be a Guest operating system, which is not limited in this application.
接下来,将对第一操作系统为Guest操作系统,第二操作系统为Host操作系统为例,对本申请的具体实施方式进行详细介绍。Next, the specific implementation manner of the present application is described in detail by taking the example that the first operating system is the guest operating system and the second operating system is the host operating system.
具体地,Guest操作系统中可以包括用户空间2011、Guest Linux Kernel2012、和Qemu 2013;在Guest操作系统的用户空间中有虚拟的图形程序接口,具体地,该图形程序接口可以是OpenGL(Open Graphics Library,开放图形实验室)API(Application Program Interface)接口,也可以是例如,Direct 3D、 Quick Draw 3D等的其他图形程序接口,本申请对此不作限制。Specifically, the guest operating system may include user space 2011, Guest Linux Kernel 2012, and Qemu 2013; there is a virtual graphics program interface in the user space of the guest operating system, specifically, the graphics program interface may be OpenGL (Open Graphics Library). , Open Graphics Lab) API (Application Program Interface) interface, which can also be, for example, Direct 3D, Other graphics program interfaces, such as Quick Draw 3D, are not limited in this application.
具体地,Host操作系统中可以包括用户空间2021和Host Linux Kernel2022;在Host操作系统的用户空间中可以安装对应于Guest操作系统中的图形程序接口的图形程序后端服务器Backend Server,具体地,可以是OpenGL Backend Server;后端服务器可以通过Host Linux Kernel中的GPU驱动程序去操作GPU设备204。Specifically, the host operating system may include a user space 2021 and a Host Linux Kernel 2022; in the user space of the Host operating system, a graphics program backend server corresponding to the graphical program interface in the Guest operating system may be installed, specifically, It is the OpenGL Backend Server; the backend server can operate the GPU device 204 through the GPU driver in the Host Linux Kernel.
具体地,共享内存203是Guest操作系统和Host操作系统互相可见的一块内存;并且该内存对于Guest操作系统和Host操作系统均处于可读和可写状态,即,Guest操作系统和Host操作系统均可以在共享内存上执行读和写操作。Specifically, the shared memory 203 is a memory that is visible to each other between the guest operating system and the host operating system; and the memory is in a readable and writable state for both the guest operating system and the host operating system, that is, both the guest operating system and the host operating system. Read and write operations can be performed on shared memory.
在具体实施时,该共享内存203可以仅包括第一存储区2031;也可以划分为第一存储区2031和第二存储区2032。具体地,该第一存储区也可以称为私有内存;该第二存储区也可以称为公共内存。在具体实施时,第一存储区和第二存储区的划分没有特定规则,可以是根据第一存储区和第二存储区各自通常存储的数据大小、依据设计人员的经验划分;也可以根据其他预先设置的策略来划分,本申请对此不作限制。In a specific implementation, the shared memory 203 may include only the first storage area 2031; and may also be divided into a first storage area 2031 and a second storage area 2032. Specifically, the first storage area may also be referred to as private memory; the second storage area may also be referred to as public memory. In a specific implementation, the division of the first storage area and the second storage area has no specific rules, and may be divided according to the data size generally stored by the first storage area and the second storage area, according to the experience of the designer; Pre-set policies are used to divide, and this application does not limit this.
具体地,第一存储区可以用于Guest操作系统的各个线程与Backend Server线程之间的函数和参数、和/或同步信息的传输;具体地,该私有内存还可以进一步被划分为多个块,一个块定义为一个通道,一个通道对应于Guest操作系统的一个线程;在具体划分时,该多个块可以是平均划分的、尺寸大小相等的块,也可以是根据系统中常用线程调用GPU的函数和参数、和/或同步信息的大小来智能划分,本申请对此不作限制。在具体实施时,Guest操作系统的用户程序可以对私有内存中的通道进行动态管理,即,用户程序可以随时对私有内存中的通道进行分配、重新分配及释放操作。Specifically, the first storage area may be used for transmission of functions and parameters between the respective threads of the Guest operating system and the Backend Server thread, and/or synchronization information; specifically, the private memory may be further divided into multiple blocks. One block is defined as one channel, one channel corresponds to one thread of the Guest operating system; in the specific division, the multiple blocks may be equally divided blocks of equal size, or may be called according to common threads in the system. The functions and parameters, and/or the size of the synchronization information are intelligently divided, and this application does not limit this. In the specific implementation, the user program of the Guest operating system can dynamically manage the channels in the private memory, that is, the user program can allocate, reallocate, and release the channels in the private memory at any time.
具体地,第二存储区可以用于Guest操作系统的所有线程与Backend Server线程之间的大数据块,例如,图形内容数据的传输。在具体实施时,可 以将公共内存划分为若干个尺寸大小不相等的大块。具体地,Guest操作系统中的用户程序可以对公共内存中的块进行管理,即,用户程序可以随时对公共内存中的通道进行分配、及释放操作,且每次分配和释放都是按整个块处理的。Specifically, the second storage area can be used for large data blocks between all threads of the Guest operating system and the Backend Server thread, for example, transmission of graphic content data. In the specific implementation, To divide the common memory into several large chunks of unequal size. Specifically, the user program in the Guest operating system can manage the blocks in the common memory, that is, the user program can allocate and release the channels in the common memory at any time, and each time the allocation and release are performed according to the entire block. Processed.
在具体实施时,公共内存中块的大小的划分可以适配于常用的GPU图形处理数据。例如,研发人员在实现本申请的过程中发现,在GPU虚拟化过程中,通常第一操作系统将2M至16M左右的图形内容数据传输至第二操作系统就能够满足GPU图形虚拟化处理的需求;而在因此,在分配公共内存中块的大小时,可以将公共内存分隔为2M,4M,8M,16M等多个内存块。In a specific implementation, the division of the size of the block in the common memory can be adapted to the commonly used GPU graphics processing data. For example, in the process of implementing the present application, the research and development personnel find that, in the process of GPU virtualization, the first operating system usually transmits about 2M to 16M of graphic content data to the second operating system to meet the requirements of GPU graphics virtualization processing. Therefore, when allocating the size of the block in the common memory, the common memory can be divided into multiple memory blocks such as 2M, 4M, 8M, and 16M.
举例来说,如果总公共内存大小为32M,分隔为2M,2M,4M,8M,16M 5个内存块,用户程序申请3M空间时,可以直接把4M的内存块区分配给相应的线程,并在该线程释放时置一个空闲标志给4M块区。For example, if the total common memory size is 32M, divided into 2M, 2M, 4M, 8M, 16M 5 memory blocks, when the user program applies for 3M space, the 4M memory block area can be directly allocated to the corresponding thread, and When the thread is released, an idle flag is set to the 4M block.
应当理解,为了示例的目的,图2中仅示出了一个Guest操作系统、一个Host操作系统及一个共享内存的情况;但在具体实施时,可以是一个或多个Guest操作系统,也可以是一个或多个Host操作系统,还可以是一个或多个共享内存;即,对于Guest操作系统、Host操作系统及共享内存可以为任意的数量,本申请对此均不作限制。It should be understood that, for the purpose of example, only one Guest operating system, one Host operating system, and one shared memory are shown in FIG. 2; but in specific implementation, it may be one or more Guest operating systems, or may be One or more Host operating systems may also be one or more shared memory; that is, the Guest operating system, the Host operating system, and the shared memory may be any number, which is not limited in this application.
应当理解,为了示例的目的,图2中示出的共享内存包括私有内存和公共内存两个存储区;并且将私有内存划分为3个大小相等的通道;公共内存被划分为4个大小不等的通道。在具体实施时,共享内存可以是仅包括私有内存一个存储区;并且私有内存可以不进行划分、或者划分为多个大小不等的通道;公共内存可以不存在,也可以被划分为多个大小相等的通道等,本申请对此均不作限制。It should be understood that, for the purpose of example, the shared memory shown in FIG. 2 includes two storage areas of private memory and common memory; and the private memory is divided into three equal-sized channels; the common memory is divided into four sizes. Channel. In a specific implementation, the shared memory may be a storage area including only private memory; and the private memory may not be divided or divided into multiple channels of different sizes; the common memory may not exist or may be divided into multiple sizes. Equal channels, etc., are not limited in this application.
接下来,将结合图2所示系统架构对根据本申请实施例的GPU的虚拟化方法进行描述。Next, a virtualization method of a GPU according to an embodiment of the present application will be described in conjunction with the system architecture shown in FIG. 2.
图3示出了根据本申请实施例一的GPU的虚拟化方法的流程图。在本申 请实施例一中,描述了以Guest操作系统作为执行主体的GPU虚拟化方法的步骤。如图3所示,根据本申请实施例的GPU的虚拟化方法包括以下步骤:FIG. 3 is a flowchart of a virtualization method of a GPU according to Embodiment 1 of the present application. In this application In the first embodiment, the steps of the GPU virtualization method using the Guest operating system as the execution subject are described. As shown in FIG. 3, a virtualization method of a GPU according to an embodiment of the present application includes the following steps:
S301,接收在Guest操作系统处的图形处理操作,并根据该图形处理操作确定对应的图形处理指令。S301. Receive a graphics processing operation at the guest operating system, and determine a corresponding graphics processing instruction according to the graphics processing operation.
在具体实施时,在S301之前,可以在Guest系统对应的Qemu启动时,创建GPU设备对应的共享内存。具体地,Qemu可以通过系统调用来创建对应的共享内存。具体地,可以从内存中划分一块特定的地址空间作为GPU设备的共享内存。该共享内存的大小可以可以由开发人员设置,并适配于GPU。例如,GPU设备对应的共享内存可以设置为128M等,本申请对此均不作限制。In a specific implementation, before S301, the shared memory corresponding to the GPU device may be created when the Qemu corresponding to the guest system is started. Specifically, Qemu can create a corresponding shared memory through a system call. Specifically, a specific address space can be divided from the memory as the shared memory of the GPU device. The size of the shared memory can be set by the developer and adapted to the GPU. For example, the shared memory corresponding to the GPU device can be set to 128M or the like, which is not limited in this application.
应当理解,当有多个Guest系统时,可以由每个Guest系统的Qemu为GPU重新创建一块共享内存,也可以是该多个Guest系统共享GPU对应的一块共享内存;本申请对此均不作限制。It should be understood that when there are multiple guest systems, a shared memory may be recreated for the GPU by the Qemu of each guest system, or a shared memory corresponding to the GPU may be shared by the multiple guest systems; .
Qemu进一步将该共享内存映射为Guest系统的PCI(Peripheral Component Interconnect,外设部件互连标准)设备内存空间;并为Guest系统提供虚拟的PCI寄存器作为PCI配置空间。Qemu further maps the shared memory to the PCI (Peripheral Component Interconnect) device memory space of the Guest system; and provides the guest system with a virtual PCI register as the PCI configuration space.
然后,Guest Linux Kernel将该共享内存划分为私有内存和公共内存。The Guest Linux Kernel then divides the shared memory into private and public memory.
具体地,Guest Linux Kernel可以在对GPU设备初始化时对共享内存进行划分;以使共享内存支持多个进程或线程的访问。具体地,可以将私有内存,即,第一存储区划分为第一预设数量的多个通道;可以将公共内存,即,第二存储区划分为第二预设数量的多个块。具体的,该第一预设数量和第二预设数量可以由开发人员设置。具体地,该私有内存的多个通道的大小可以相等;该公共内存的多个块的大小可以适配于该共享内存对应的物理设备的处理数据。Specifically, the Guest Linux Kernel can partition the shared memory when initializing the GPU device; so that the shared memory supports access by multiple processes or threads. Specifically, the private memory, that is, the first storage area may be divided into a first preset number of multiple channels; the common memory, that is, the second storage area may be divided into a second preset number of multiple blocks. Specifically, the first preset number and the second preset number may be set by a developer. Specifically, the size of the multiple channels of the private memory may be equal; the size of the multiple blocks of the common memory may be adapted to the processing data of the physical device corresponding to the shared memory.
进一步的,在S301之前,还可以包括在前端线程启动时,为该前端线程、以及对应的后端线程分配相应的共享内存地址空间的步骤。 Further, before S301, the step of allocating a corresponding shared memory address space for the front-end thread and the corresponding back-end thread may be included when the front-end thread is started.
在具体实施时,当接收到API调用指令时,可以创建与该API调用指令对应的前端线程。并将API调用指令对应的线程创建指令发送到Host操作系统,以触发Host操作系统创建相应的后端线程。在前端线程和后端线程的创建过程中,还可以从Guest Linux Kernel处获取该前端线程对应的私有内存通道的地址空间、以及分配给该前端线程的公共内存地址空间;并将该前端线程对应的私有内存通道的地址空间、以及分配给该前端线程的公共内存地址空间映射为该前端线程的地址空间;从而与Qemu建立同步控制通道。具体地,通常将私有内存中的某一通道分配给该前端线程,并将公共内存整个分配给该前端线程。In a specific implementation, when an API call instruction is received, a front-end thread corresponding to the API call instruction may be created. The thread creation instruction corresponding to the API call instruction is sent to the Host operating system to trigger the Host operating system to create a corresponding backend thread. During the creation of the front-end thread and the back-end thread, the address space of the private memory channel corresponding to the front-end thread and the common memory address space allocated to the front-end thread may also be obtained from the Guest Linux Kernel; and the front-end thread is correspondingly The address space of the private memory channel and the common memory address space allocated to the front-end thread are mapped to the address space of the front-end thread; thereby establishing a synchronous control channel with Qemu. Specifically, a certain channel in the private memory is usually allocated to the front-end thread, and the common memory is entirely allocated to the front-end thread.
接下来,可以将该前端线程对应的私有内存通道的地址空间、以及公共内存的地址空间通过PCI配置空间传递给Qemu;然后Qemu通过进程间通信机制把前端线程对应的私有内存通道的地址空间、以及公共内存的地址空间发送给后端服务器;并将其映射为该后端线程的地址空间。Next, the address space of the private memory channel corresponding to the front-end thread and the address space of the common memory can be transferred to Qemu through the PCI configuration space; then Qemu uses the inter-process communication mechanism to address the address space of the private memory channel corresponding to the front-end thread, And the address space of the public memory is sent to the backend server; and it is mapped to the address space of the backend thread.
至此,就完成了前端线程与后端线程之间共享内存的初始化。At this point, the initialization of the shared memory between the front-end thread and the back-end thread is completed.
在具体实施时,用户通常针对Guest操作系统中的某一线程执行图形处理操作,该图形处理操作可以是例如,打开一个新窗口,打开一个新页面等。可以理解,在本步骤之前,还可以包括用户在Guest操作系统的用户空间创建一个新的线程的步骤。在具体实施时,该新的线程可以是一个应用程序,例如,QQ、微信等。用户创建新线程的行为可以是例如,用户打开微信等。In a specific implementation, the user typically performs a graphics processing operation on a thread in the guest operating system, which may be, for example, opening a new window, opening a new page, or the like. It can be understood that, before this step, the step of creating a new thread in the user space of the Guest operating system may also be included. In a specific implementation, the new thread may be an application, such as QQ, WeChat, and the like. The behavior of the user creating a new thread may be, for example, the user opening WeChat or the like.
具体地,可以进一步将第一存储区划分为一个或多个通道,如果该第一存储区包括多个通道;则在该图形处理指令写入至该共享内存之前,还包括:根据图形处理指令对应的线程,确定该图形处理指令对应的通道。Specifically, the first storage area may be further divided into one or more channels, and if the first storage area includes multiple channels, before the graphics processing instruction is written to the shared memory, the method further includes: processing the instruction according to the graphics The corresponding thread determines the channel corresponding to the graphics processing instruction.
在用户在Guest操作系统的用户空间创建一个新的线程时,即可以根据预先设置的规则为该线程分配一个对应的第一存储区的通道。具体地,该规则可以是按照线程创建的先后顺序。例如,在一个新的线程创建时,Guest Linux kernel为该线程分配一个唯一的通道号,并把该通道号对应的私有内存及整个 公共内存同时映射给用户程序;Guest用户程序通过Qemu通知OpenGL Backend Server创建一个线程,并且将相应的私有内存通道号及整个公共内存空间映射给该线程。应当理解,在具体实施时,如果私有内存仅有一个通道,则可以不执行分配通道号这一步骤;也可以不执行根据图形处理指令对应的线程,确定该图形处理指令对应的通道这一步骤。When a user creates a new thread in the user space of the guest operating system, the thread can be assigned a corresponding channel of the first storage area according to a preset rule. Specifically, the rule may be in the order in which the threads are created. For example, when a new thread is created, the Guest Linux kernel assigns a unique channel number to the thread, and the private memory corresponding to the channel number and the whole The public memory is simultaneously mapped to the user program; the Guest user program notifies OpenGL Backend Server to create a thread through Qemu, and maps the corresponding private memory channel number and the entire common memory space to the thread. It should be understood that, in the specific implementation, if there is only one channel in the private memory, the step of allocating the channel number may not be performed; or the step corresponding to the thread corresponding to the graphics processing instruction may be not performed, and the step corresponding to the channel corresponding to the graphics processing instruction may be determined. .
S302,将该图形处理指令通过共享内存传递至第二操作系统,以使该第二操作系统执行该图形处理指令,得到处理结果。S302. Pass the graphics processing instruction to the second operating system through the shared memory, so that the second operating system executes the graphics processing instruction to obtain a processing result.
在具体实施时,将该图形处理指令通过共享内存传递至第二操作系统可以通过以下方式实施:将该图形处理指令写入至该共享内存;将该图形处理指令在该共享内存的偏移地址发送至该第二操作系统。具体地,Guest用户程序可以对每一块分配的内存执行偏移记录,即,记录当前写入图形处理指令的内存在当前线程对应的内存块内的偏移地址;然后把当前内存块的偏移地址发送到Host操作系统中对应的线程。然后,Host操作系统可以通过对应的通道号和偏移地址,到共享内存的相应位置读取图形处理指令,并立即执行函数,得到处理结果。In a specific implementation, the transferring the graphics processing instruction to the second operating system through the shared memory may be implemented by: writing the graphics processing instruction to the shared memory; and offsetting the graphics processing instruction in the shared memory Sent to the second operating system. Specifically, the guest user program may perform an offset record on the memory allocated for each block, that is, record the offset address of the memory currently written in the graphics processing instruction in the memory block corresponding to the current thread; and then shift the offset of the current memory block. The address is sent to the corresponding thread in the Host operating system. Then, the host operating system can read the graphics processing instruction to the corresponding position of the shared memory through the corresponding channel number and offset address, and immediately execute the function to obtain the processing result.
在第一种具体实施方式中,该图形处理指令可以仅包括图形处理函数和参数;则可以将该图形处理函数和参数存储至该共享内存的第一存储区,即,私有内存。Host操作系统在获取到相应的图形处理函数和参数之后,可以立即执行函数,得到处理结果。具体地,为节省数据传输量,可以先确定该图形处理函数对应的编号;然后将该图形处理函数编号和参数写入至该第一存储区。Host操作系统在获取到相应的图形处理函数编号后,根据编号确定对应的图形处理函数,再根据图形处理函数和参数,执行函数,得到处理结果。具体地,该图形处理函数可以是OpenGL函数。In a first embodiment, the graphics processing instructions may only include graphics processing functions and parameters; the graphics processing functions and parameters may be stored in a first memory area of the shared memory, ie, private memory. After the Host operating system obtains the corresponding graphics processing functions and parameters, it can execute the function immediately and get the processing result. Specifically, to save the data transmission amount, the number corresponding to the graphics processing function may be determined first; then the graphics processing function number and parameters are written to the first storage area. After obtaining the corresponding graphics processing function number, the host operating system determines the corresponding graphics processing function according to the number, and then executes the function according to the graphics processing function and parameters, and obtains the processing result. Specifically, the graphics processing function may be an OpenGL function.
在第二种具体实施方式中,该图形处理指令除图形处理函数和参数之外,还包括同步信息,该同步信息用于指示该第二操作系统执行该图形处理指令的时刻;则可以将该图形处理函数和参数、以及同步信息均存储至该共享内 存的第一存储区,即,私有内存。Host操作系统在获取到相应的图形处理函数和参数之后,可以在同步信息指示的时刻执行函数,得到处理结果。In a second embodiment, the graphics processing instruction includes, in addition to the graphics processing function and the parameter, synchronization information, where the synchronization information is used to indicate the time when the second operating system executes the graphics processing instruction; Graphics processing functions and parameters, as well as synchronization information are stored in the share The first storage area that is stored, that is, private memory. After obtaining the corresponding graphics processing function and parameters, the host operating system can execute the function at the time indicated by the synchronization information, and obtain the processing result.
在第三种具体实施方式中,该图形处理指令除图形处理函数和参数之外,还包括图形内容数据;则可以将该图形处理函数和参数存储至该共享内存的私有内存,将该图形内容数据写入至第二存储区,即公共内存。Guest用户程序把私有内存块的偏移地址和公共内存块的偏移地址均发送到Host操作系统中对应的线程。然后,Host操作系统可以通过对应的通道号和私有内存偏移地址;到私有内存的相应位置读取图形处理函数和参数;通过公共内存偏移地址到公共内存的相应位置读取图形内容数据,并在读取后立即执行函数,得到处理结果。具体地,该图形内容数据可以是指需要进行图像处理的图像帧。In a third embodiment, the graphics processing instruction includes graphics content data in addition to graphics processing functions and parameters; the graphics processing function and parameters may be stored in the shared memory of the shared memory, and the graphics content is The data is written to the second storage area, which is the common memory. The Guest user program sends the offset address of the private memory block and the offset address of the common memory block to the corresponding thread in the Host operating system. Then, the host operating system can read the graphic processing function and parameters through the corresponding channel number and the private memory offset address; to the corresponding position of the private memory; and read the graphic content data through the common memory offset address to the corresponding position of the common memory, And execute the function immediately after reading, and get the processing result. Specifically, the graphic content data may refer to an image frame that requires image processing.
具体地,可以进一步将公共内存划分为多个、具有适配于GPU图形内容数据的大小的块;如果该第二存储区包括多个块;则在将图形内容数据写入至所述第二存储区之前,还可以包括:根据图形内容数据的大小,确定图形内容数据对应的块。Specifically, the common memory may be further divided into a plurality of blocks having a size adapted to the GPU graphic content data; if the second storage area includes a plurality of blocks, the graphic content data is written to the second Before the storage area, the method further includes: determining, according to the size of the graphic content data, a block corresponding to the graphic content data.
举例来说,如果总公共内存大小为32M,分隔为2M,2M,4M,8M,16M 5个内存块,用户程序申请传递3M的数据内容数据时,可以直接把4M的公共内存块分配给相应的线程。For example, if the total common memory size is 32M, divided into 2M, 2M, 4M, 8M, 16M 5 memory blocks, when the user program requests to transfer 3M data content data, you can directly allocate 4M common memory blocks to the corresponding the rout.
在第四种具体实施方式中,该图形处理指令除图形处理函数、参数和同步信息之外,还包括图形内容数据;则可以将该图形处理函数、参数和同步信息存储至该共享内存的私有内存,将该图形内容数据写入至第二存储区,即公共内存。Guest用户程序把私有内存块的偏移地址和公共内存块的偏移地址均发送到Host操作系统中对应的线程。然后,Host操作系统可以通过对应的通道号和私有内存偏移地址;到私有内存的相应位置读取图形处理函数、参数和同步信息;通过公共内存偏移地址到公共内存的相应位置读取图形内容数据,并在同步信息指示的时刻执行函数,得到处理结果。 In a fourth specific embodiment, the graphics processing instruction includes graphics content data in addition to graphics processing functions, parameters, and synchronization information; the graphics processing function, parameters, and synchronization information may be stored in the shared memory private The memory writes the graphic content data to the second storage area, that is, the common memory. The Guest user program sends the offset address of the private memory block and the offset address of the common memory block to the corresponding thread in the Host operating system. Then, the host operating system can read the graphics processing function, parameters, and synchronization information through the corresponding channel number and the private memory offset address; to the corresponding position in the private memory; and read the graphic through the common memory offset address to the corresponding position of the common memory. The content data is executed at the time indicated by the synchronization information, and the processing result is obtained.
应当理解,在具体实施时,第一操作系统和第二操作之间可以一次或多次利用共享内存来传递下述数据中的任意一种或多种:图形处理函数或图形处理函数编号、参数、同步信息、图形内容数据。具体地,第一操作系统可以一次就将待传递的图形处理指令通过共享内存传递至第二操作系统;也可以将图形处理指令拆分成适当的大小,多次利用共享内存传递至第二操作系统;在具体实施时,对图形处理指令的拆分策略可以采用本领域技术人员的常用技术手段,本申请对此不作限制。It should be understood that, in a specific implementation, the shared memory may be utilized one or more times between the first operating system and the second operation to deliver any one or more of the following data: a graphics processing function or a graphics processing function number, a parameter , synchronization information, graphic content data. Specifically, the first operating system may transfer the graphics processing instruction to be delivered to the second operating system through the shared memory at one time; or may split the graphics processing instruction into an appropriate size and use the shared memory to transfer to the second operation multiple times. The system does not limit the splitting strategy of the graphics processing instructions by using the common technical means of those skilled in the art.
S303,第二操作系统将该处理结果作为该图形处理操作的响应进行显示。S303. The second operating system displays the processing result as a response of the graphics processing operation.
在具体实施时,第二操作系统在得到处理结果后,可以通过GPU设备将处理结果显示至屏幕。In a specific implementation, after obtaining the processing result, the second operating system may display the processing result to the screen through the GPU device.
S304,第一操作系统接收来自第二操作系统的执行结果。S304. The first operating system receives an execution result from the second operating system.
在具体实施时,第二操作系统可以根据函数的执行结果,生成执行结果。具体地,该执行结果可以包括图形处理函数执行成功或失败的消息、和/或软件版本信息等;并返回给第一操作系统;以使得第一操作系统中的的相应线程能够获取该函数的执行。In a specific implementation, the second operating system may generate an execution result according to the execution result of the function. Specifically, the execution result may include a message that the graphics processing function performs success or failure, and/or software version information, etc.; and returns to the first operating system; so that the corresponding thread in the first operating system can acquire the function. carried out.
具体地,Host操作系统可以将执行结果写入共享内存;并记录当前写入执行结果的位置,在当前线程对应的内存块内的偏移地址;然后把该偏移地址发送到Guest操作系统中对应的线程。然后,Guest操作系统可以通过对应的偏移地址,到共享内存的相应位置读取数据。Specifically, the host operating system can write the execution result to the shared memory; and record the current write execution result position, the offset address in the memory block corresponding to the current thread; and then send the offset address to the guest operating system. Corresponding thread. Then, the Guest operating system can read the data to the corresponding location of the shared memory through the corresponding offset address.
至此,实现了Guest操作系统中用户程序对GPU设备的远程调用;即,实现了GPU的虚拟化。So far, the remote call of the GPU device by the user program in the Guest operating system is realized; that is, the virtualization of the GPU is realized.
采用本申请实施例中的GPU的虚拟化方法,在共享内存的基础上实现了OpenGL API的远程调用,从而实现GPU的虚拟化。With the virtualization method of the GPU in the embodiment of the present application, the remote call of the OpenGL API is implemented on the basis of the shared memory, thereby realizing the virtualization of the GPU.
实施例二Embodiment 2
图4示出了根据本申请实施例二的GPU的虚拟化方法的流程图。在本申 请实施例二中,描述了以Host操作系统作为执行主体的GPU虚拟化方法的步骤。本申请实施例中的系统架构的实施可以参见实施例一中图2所示的系统架构,重复之处不再赘述。FIG. 4 is a flowchart of a virtualization method of a GPU according to Embodiment 2 of the present application. In this application In the second embodiment, the steps of the GPU virtualization method using the Host operating system as the execution body are described. For the implementation of the system architecture in the embodiment of the present application, refer to the system architecture shown in FIG. 2 in the first embodiment, and details are not described herein again.
如图4所示,根据本申请实施例的GPU的虚拟化方法包括以下步骤:As shown in FIG. 4, a virtualization method of a GPU according to an embodiment of the present application includes the following steps:
S401,Host操作系统通过共享内存获取来自Guest操作系统的图形处理指令。S401. The host operating system acquires graphics processing instructions from the guest operating system through the shared memory.
在具体实施时,共享内存可以划分为私有内存和公共内存;并且私有内存可以进一步划分为对应于不同线程的多个通道;如果私有内存包括多个通道,则在S401之前,还包括:所述图形处理指令对应的线程,确定该图形处理指令对应的通道。In a specific implementation, the shared memory may be divided into private memory and common memory; and the private memory may be further divided into multiple channels corresponding to different threads; if the private memory includes multiple channels, before S401, the method further includes: A thread corresponding to the graphics processing instruction determines a channel corresponding to the graphics processing instruction.
具体地,可以在用户在Guest操作系统的用户空间创建一个新的线程时,即可以根据预先设置的规则为该线程分配一个对应的第一存储区的通道。具体地,该规则可以是按照线程创建的先后顺序。例如,在一个新的线程创建时,Guest Linux kernel为该线程分配一个唯一的通道号,并把该通道号对应的私有内存及整个公共内存同时映射给用户程序;Guest用户程序通过Qemu通知OpenGL Backend Server创建一个线程,并且将相应的私有内存通道号及整个公共内存空间映射给该线程。应当理解,在具体实施时,如果私有内存仅有一个通道,则可以不执行分配通道号这一步骤;也可以不执行根据图形处理指令对应的线程,确定该图形处理指令对应的通道这一步骤。Specifically, when the user creates a new thread in the user space of the guest operating system, the thread may be allocated a corresponding channel of the first storage area according to a preset rule. Specifically, the rule may be in the order in which the threads are created. For example, when a new thread is created, the Guest Linux kernel assigns a unique channel number to the thread, and maps the private memory corresponding to the channel number and the entire public memory to the user program at the same time; the Guest user program notifies OpenGL Backend through Qemu. Server creates a thread and maps the corresponding private memory channel number and the entire public memory space to the thread. It should be understood that, in the specific implementation, if there is only one channel in the private memory, the step of allocating the channel number may not be performed; or the step corresponding to the thread corresponding to the graphics processing instruction may be not performed, and the step corresponding to the channel corresponding to the graphics processing instruction may be determined. .
在具体实施时,Guest操作系统可以将图形处理指令在共享内存的偏移地址发送至Host操作系统;Host操作系统根据该图形处理指令在共享内存的偏移地址,从共享内存读取该图形处理指令。In a specific implementation, the guest operating system may send the graphics processing instruction to the host operating system at an offset address of the shared memory; the host operating system reads the graphics processing from the shared memory according to the offset address of the shared memory according to the graphics processing instruction. instruction.
在第一种具体实施方式中,该图形处理指令仅包括图形处理函数和参数时;Host操作系统可以在私有内存中获取到相应的图形处理函数和参数。如果在私有内存中获取到的是图形处理函数的编号,则可以根据编号确定对应的图形处理函数,再根据图形处理函数和参数。 In the first embodiment, the graphics processing instruction only includes the graphics processing function and the parameter; the host operating system can obtain the corresponding graphics processing function and parameters in the private memory. If the number of the graphics processing function is obtained in the private memory, the corresponding graphics processing function can be determined according to the number, and the function and parameters are processed according to the graphics.
在第二种具体实施方式中,该图形处理指令除图形处理函数和参数之外,还包括同步信息,该同步信息用于指示该第二操作系统执行该图形处理指令的时刻;Host操作系统可以在私有内存中获取到相应的图形处理函数、参数和同步信息。In a second embodiment, the graphics processing instruction includes, in addition to the graphics processing function and the parameter, synchronization information, where the synchronization information is used to indicate the time when the second operating system executes the graphics processing instruction; Obtain the corresponding graphics processing functions, parameters, and synchronization information in private memory.
在第三种具体实施方式中,该图形处理指令除图形处理函数和参数之外,还包括图形内容数据;则Host操作系统可以通过对应的通道号和私有内存偏移地址;到私有内存的相应位置读取图形处理函数和参数;通过公共内存偏移地址到公共内存的相应位置读取图形内容数据。In a third specific implementation, the graphics processing instruction includes graphic content data in addition to the graphics processing function and parameters; the host operating system can pass the corresponding channel number and the private memory offset address; corresponding to the private memory The position reads the graphics processing function and parameters; the graphic content data is read through the common memory offset address to the corresponding position of the common memory.
在第四种具体实施方式中,该图形处理指令除图形处理函数、参数和同步信息之外,还包括图形内容数据;则Host操作系统可以通过对应的通道号和私有内存偏移地址;到私有内存的相应位置读取图形处理函数、参数和同步信息;通过公共内存偏移地址到公共内存的相应位置读取图形内容数据。In a fourth specific implementation, the graphics processing instruction includes graphic content data in addition to the graphics processing function, parameters, and synchronization information; the host operating system may pass the corresponding channel number and the private memory offset address; The corresponding position of the memory reads the graphics processing function, parameters and synchronization information; the graphic content data is read through the common memory offset address to the corresponding position of the common memory.
S402,Host操作系统执行该图形处理指令,得到处理结果。S402. The host operating system executes the graphic processing instruction to obtain a processing result.
在具体实施时,如果图形处理指令中包括同步信息,则Host操作系统在获取到图形处理指令后,可以在同步信息指示的时刻基于参数执行图形处理函数,并得到处理结果。In a specific implementation, if the synchronization processing information is included in the graphics processing instruction, after acquiring the graphics processing instruction, the host operating system may execute the graphics processing function based on the parameter at the moment indicated by the synchronization information, and obtain the processing result.
在具体实施时,图形处理指令中不包括同步信息,则Host操作系统在获取到图形处理指令后,可以立即基于参数执行图形处理函数,并得到处理结果。In the specific implementation, the synchronization processing information is not included in the graphics processing instruction, and after the host operating system acquires the graphics processing instruction, the host operating system can immediately execute the graphics processing function based on the parameters, and obtain the processing result.
S403,将处理结果作为在第一操作系统处接收到的图形处理操作的响应进行显示。S403. Display the processing result as a response to the graphics processing operation received at the first operating system.
在具体实施时,Host操作系统显示函数处理结果的过程可以采用本领域技术人员的常规技术手段,本申请对此不作赘述。In the specific implementation, the process of the host operating system displaying the function processing result may adopt the conventional technical means of those skilled in the art, which is not described in this application.
S404,将执行结果通过共享内存传递至第一操作系统。S404. Pass the execution result to the first operating system through the shared memory.
在具体实施时,在Host操作系统得到处理结果后,可以再将函数的执行结果,例如,用于标识函数执行成功或者执行失败的消息,写入该共享内存; 并将该消息在该共享内存的偏移地址发送至该第一操作系统,以使第一操作系统根据该偏移地址,获取该函数执行结果。In a specific implementation, after the host operating system obtains the processing result, the execution result of the function, for example, a message for identifying that the function execution succeeds or the execution failure is written, may be written into the shared memory; And sending the message to the first operating system at the offset address of the shared memory, so that the first operating system obtains the function execution result according to the offset address.
至此,实现了在Host操作系统中,配合Guest操作系统中的用户程序对GPU设备的远程调用;即,实现了GPU的虚拟化。At this point, the remote calling of the GPU device is implemented in the Host operating system in conjunction with the user program in the Guest operating system; that is, the virtualization of the GPU is implemented.
采用本申请实施例中的GPU的虚拟化方法,在共享内存的基础上实现了OpenGL API的远程调用,从而实现GPU的虚拟化。With the virtualization method of the GPU in the embodiment of the present application, the remote call of the OpenGL API is implemented on the basis of the shared memory, thereby realizing the virtualization of the GPU.
实施例三Embodiment 3
图5示出了根据本申请实施例三的GPU的虚拟化方法的流程图。在本申请实施例三中,描述了以OpenGL图形处理接口为例,Guest操作系统与Host操作系统配合实现GPU虚拟化方法的步骤。本申请实施例中的系统架构的实施可以参见实施例一中图2所示的系统架构,重复之处不再赘述。FIG. 5 is a flowchart of a virtualization method of a GPU according to Embodiment 3 of the present application. In the third embodiment of the present application, the step of implementing the GPU virtualization method by using the OpenGL graphics processing interface as an example, the Guest operating system and the Host operating system are described. For the implementation of the system architecture in the embodiment of the present application, refer to the system architecture shown in FIG. 2 in the first embodiment, and details are not described herein again.
在本申请实施例中,OpenGL API函数远程调用的发起方为Guest操作系统,函数执行方为Host操作系统,从Guest操作系统到Host操作系统的下行同步过程经历Guest Linux kernel、Qemu到达OpenGL Backend Server;从Host操作系统到Guest操作系统的上行同步过程从OpenGL Backend Server发起,经过Qemu、Guest Linux kernel到达OpenGL emulator API。In the embodiment of the present application, the initiator of the OpenGL API function remote call is the Guest operating system, and the function execution party is the Host operating system. The downlink synchronization process from the Guest operating system to the Host operating system goes through the Guest Linux kernel and Qemu reaches the OpenGL Backend Server. The uplink synchronization process from the Host operating system to the Guest operating system is initiated from the OpenGL Backend Server and reaches the OpenGL emulator API via the Qemu and Guest Linux kernels.
在本申请实施例中,Guest操作系统每次创建一个新的显示窗口,就会相应地创建一个线程去初始化并调用OpenGL函数,在初始化过程中,OpenGL Backend Server同样会创建一个与Guest端一一对应的线程。In the embodiment of the present application, each time the guest operating system creates a new display window, a thread is created to initialize and call the OpenGL function. During the initialization process, the OpenGL Backend Server also creates a guest interface with the guest. Corresponding thread.
接下来,将对基于上述应用场景的GPU虚拟方法的实施过程进行详细描述。Next, the implementation process of the GPU virtual method based on the above application scenario will be described in detail.
如图5所示,根据本申请实施例三的GPU的虚拟化方法包括以下步骤:As shown in FIG. 5, the virtualization method of the GPU according to Embodiment 3 of the present application includes the following steps:
S501,共享内存初始化。S501, shared memory initialization.
在具体实施时,可以在Guest Linux kernel把共享内存划分为两大块,分别定义为私有内存及公共内存。 In the specific implementation, the shared memory can be divided into two large blocks in the Guest Linux kernel, which are defined as private memory and common memory.
具体地,可以把私有内存平均划分成若干个尺寸大小相等的块,一个块即为一个通道,每一个通道用于Guest操作系统的一个线程到OpenGL Backend Server线程的数据及同步信息的传输。具体地,该数据可以包括图形处理函数编号和参数。Specifically, the private memory may be equally divided into a plurality of blocks of equal size, and one block is a channel, and each channel is used for transmitting data and synchronization information of a thread of the Guest operating system to an OpenGL Backend Server thread. In particular, the data may include graphics processing function numbers and parameters.
具体地,可以把公共内存划分成若干个尺寸大小不相等的大块,用于Guest操作系统的所有线程到OpenGL Backend Server线程的大数据块传输。Specifically, the common memory can be divided into a plurality of large unequal chunks for large data block transmission from all threads of the Guest operating system to the OpenGL Backend Server thread.
S502,建立共享内存与线程的映射。S502, establishing a mapping of shared memory and threads.
在具体实施时,可以由Guest Linux kernel控制私有通道的编号,当Guest用户程序每次创建一个新的线程时,kernel负责分配一个唯一的通道号,并把该通道对应的私有内存及整个公共内存同时映射给用户程序。In the specific implementation, the number of the private channel can be controlled by the Guest Linux kernel. When the Guest user program creates a new thread each time, the kernel is responsible for allocating a unique channel number, and the private memory corresponding to the channel and the entire public memory. Also map to the user program.
然后由Guest用户程序通过Qemu通知OpenGL Backend Server创建一个线程并使用对应的私有通道内存及整个公共内存空间。Then the Guest user program tells OpenGL Backend Server to create a thread through Qemu and use the corresponding private channel memory and the entire public memory space.
Guest用户程序对私有通道内存进行动态管理,程序可以随时在私有内存进行分配,重新分配及释放操作。The guest user program dynamically manages the private channel memory, and the program can allocate, redistribute, and release operations in the private memory at any time.
Guest用户程序对公共内存进行固定尺寸大小管理,每次分配和释放都是按整个块处理的,举例来说,如果总公共内存大小为32M,分隔为2M,2M,4M,8M,16M 5个内存块,用户申请3M空间时,直接把4M的内存块区分配出去,释放时置一个空闲标志给4M块区。The Guest user program manages the fixed size of the common memory. Each allocation and release is handled by the entire block. For example, if the total public memory size is 32M, the partition is 2M, 2M, 4M, 8M, 16M 5 In the memory block, when the user applies for 3M space, the 4M memory block area is directly allocated, and an idle flag is set to the 4M block area when released.
Guest用户程序对每一块分配的内存执行偏移记录,即,记录当前分配的内存在整个跨系统内存块的偏移地址。The Guest user program performs an offset record on each allocated memory, that is, records the offset address of the currently allocated memory across the entire system memory block.
S503,Guest用户程序响应于用户的图形处理操作,确定相应的图形处理指令。S503. The Guest user program determines a corresponding graphics processing instruction in response to the user's graphics processing operation.
步骤S503的实施可以参考实施例一中S301的实施,重复之处不再赘述。For the implementation of step S503, reference may be made to the implementation of S301 in the first embodiment, and the repeated description is omitted.
S504,Guest用户程序把函数编号及其参数写到分配的内存块后,把函数编号和参数在当前内存块的偏移地址传到Host操作系统对应的线程。S504: After the guest user program writes the function number and its parameters to the allocated memory block, the function number and the parameter are transferred to the thread corresponding to the host operating system at the offset address of the current memory block.
步骤S504的实施可以参考实施例一S302中函数编号和参数的传递过程 的实施,重复之处不再赘述。For the implementation of step S504, reference may be made to the process of transmitting the function number and parameters in the first embodiment S302. The implementation, repetitions will not be repeated.
S505,Host操作系统从共享内存中获取传递过来的函数编号及其参数,并开始执行函数。S505: The host operating system acquires the passed function number and its parameters from the shared memory, and starts executing the function.
步骤S505的实施可以参考实施例二S401中函数编号和参数的获取过程,以及实施例二S402中函数执行过程的实施,重复之处不再赘述。For the implementation of step S505, reference may be made to the process of obtaining the function number and parameters in the second embodiment S401, and the implementation of the function execution process in the second embodiment S402, and the repeated description is omitted.
S506,Host操作系统执行完函数后,显示处理结果,并用同样的方法把标识函数执行成功或失败的消息写在共享内存里,再把相应的偏移地址返回给Guest操作系统,完成一次函数的执行。S506, after the Host operating system executes the function, the processing result is displayed, and the same method is used to write the success or failure of the identification function in the shared memory, and then the corresponding offset address is returned to the Guest operating system to complete the function. carried out.
步骤S506的实施可以参考实施例二S403和S404的实施,重复之处不再赘述。For the implementation of step S506, reference may be made to the implementation of the second embodiment S403 and S404, and the repeated description is not repeated.
至此,实现了在Guest操作系统和Host操作系统之间的OpenGL API的远程调用,从而实现GPU的虚拟化。At this point, the remote call of the OpenGL API between the Guest operating system and the Host operating system is implemented, thereby realizing the virtualization of the GPU.
采用本申请实施例中的GPU的虚拟化方法,使用了跨操作系统共享内存的方法,也就是说两个操作系统互相可见在一块内存上进行的读写操作,在共享内存的基础上实现了OpenGL API的远程调用,从而实现GPU的虚拟化。The virtualization method of the GPU in the embodiment of the present application uses a method of sharing memory across operating systems, that is, two operating systems are mutually visible and read and written on one memory, and implemented on the basis of shared memory. Remote calls to the OpenGL API to virtualize the GPU.
基于同一发明构思,本申请实施例中还提供了一种GPU的虚拟化装置,由于该装置解决问题的原理与本申请实施例一所提供的GPU的虚拟化方法的相似,因此该装置的实施可以参见方法的实施,重复之处不再赘述。Based on the same inventive concept, a GPU virtualization device is also provided in the embodiment of the present application. The principle of the device is similar to the GPU virtualization method provided in the first embodiment of the present application. See the implementation of the method, and the repetition will not be repeated.
实施例四Embodiment 4
图6示出了根据本申请实施例四的GPU的虚拟化装置的结构示意图。FIG. 6 is a schematic structural diagram of a virtualization device of a GPU according to Embodiment 4 of the present application.
如图6所示,根据本申请实施例四的GPU的虚拟化装置600包括:第一接收模块601,用于接收在第一操作系统处的图形处理操作,并根据该图形处理操作确定对应的图形操作指令;第一传递模块602,用于将该图形处理指令通过共享内存传递至该第二操作系统,以使该第二操作系统执行该图形处理指令,得到处理结果,并将处理结果作为图形处理操作的响应进行显示;其 中,该共享内存对该第一操作系统和第二操作系统均处于可读和可写状态。As shown in FIG. 6, the virtualization device 600 of the GPU according to Embodiment 4 of the present application includes: a first receiving module 601, configured to receive a graphics processing operation at a first operating system, and determine a corresponding according to the graphics processing operation. a graphics operation instruction; the first delivery module 602 is configured to pass the graphics processing instruction to the second operating system through the shared memory, so that the second operating system executes the graphics processing instruction, obtains a processing result, and uses the processing result as The response of the graphics processing operation is displayed; The shared memory is in a readable and writable state for both the first operating system and the second operating system.
具体地,该第一操作系统可以为客Guest操作系统,该第二操作系统可以为主Host操作系统。Specifically, the first operating system may be a guest guest operating system, and the second operating system may be a host guest operating system.
具体地,第一传递模块,具体可以包括:第一写入子模块,将该图形处理指令写入至该共享内存;第一发送子模块,用于将该图形处理指令在该共享内存的偏移地址发送至该第二操作系统。Specifically, the first delivery module may specifically include: a first writing submodule, the graphic processing instruction is written to the shared memory; and the first sending submodule is configured to bias the graphic processing instruction in the shared memory The transfer address is sent to the second operating system.
具体地,该图形处理指令可以包括图形处理函数和参数;第一写入子模块,具体可以用于:将图形处理指令存储至该共享内存的第一存储区。Specifically, the graphics processing instruction may include a graphics processing function and a parameter; the first writing sub-module may be specifically configured to: store the graphics processing instruction into the first storage area of the shared memory.
具体地,该图形处理指令还可以包括同步信息,该同步信息可以用于指示该第二操作系统执行该图形处理指令的时刻。Specifically, the graphics processing instruction may further include synchronization information, where the synchronization information may be used to indicate a timing at which the second operating system executes the graphics processing instruction.
具体地,该图形处理指令还可以包括图形内容数据;该共享内存还可以包括第二存储区;第一写入子模块,还可以用于:将该图形内容数据写入至该第二存储区。Specifically, the graphics processing instruction may further include graphic content data; the shared memory may further include a second storage area; the first writing sub-module may further be configured to: write the graphic content data to the second storage area .
具体地,第二存储区包括多个块,其中,各块具有预先设置的大小,预先设置的大小适配于GPU图形内容数据;该装置还可以包括:第一确定模块,用于根据图形内容数据的大小,确定图形内容数据对应的块。Specifically, the second storage area includes a plurality of blocks, wherein each block has a preset size, and the preset size is adapted to the GPU graphic content data; the device may further include: a first determining module, configured to use the graphic content according to the graphic content The size of the data determines the block corresponding to the graphic content data.
具体地,该第一存储区包括多个通道,其中,各通道对应于不同的线程;该装置还可以包括:第二确定模块,用于根据图形处理指令对应的线程,确定该图形处理指令对应的通道。Specifically, the first storage area includes a plurality of channels, wherein each channel corresponds to a different thread; the device may further include: a second determining module, configured to determine, according to the thread corresponding to the graphics processing instruction, the graphics processing instruction Channel.
具体地,该图形处理指令可以包括图形处理函数对应的编号和参数;第一写入子模块,具体可以用于:确定该图形处理函数对应的编号;将该图形处理函数编号和参数写入至该第一存储区。Specifically, the graphics processing instruction may include a number and a parameter corresponding to the graphics processing function; the first writing sub-module may be specifically configured to: determine a number corresponding to the graphics processing function; and write the graphics processing function number and parameters to The first storage area.
具体地,根据本申请实施例的GPU虚拟化装置还包括:第二接收模块603,用于接收来自第二操作系统的执行结果。Specifically, the GPU virtualization apparatus according to the embodiment of the present application further includes: a second receiving module 603, configured to receive an execution result from the second operating system.
具体地,第二接收模块,具体可以包括:第一地址接收子模块,用于接收来自第二操作系统的执行结果在共享内存的偏移地址;第一读取子模块, 用于根据执行结果在共享内存的偏移地址,从共享内存读取执行结果。Specifically, the second receiving module may further include: a first address receiving submodule, configured to receive an offset address of the execution result from the second operating system in the shared memory; the first reading submodule, Used to read the execution result from the shared memory based on the offset address of the shared memory according to the execution result.
采用本申请实施例中的GPU的虚拟化装置,在共享内存的基础上实现了OpenGL API的远程调用,从而实现GPU的虚拟化。With the virtualization device of the GPU in the embodiment of the present application, the remote call of the OpenGL API is implemented on the basis of the shared memory, thereby realizing the virtualization of the GPU.
基于同一发明构思,本申请实施例中还提供了一种GPU的虚拟化装置,由于该装置解决问题的原理与本申请实施例二所提供的GPU的虚拟化方法的相似,因此该装置的实施可以参见方法的实施,重复之处不再赘述。Based on the same inventive concept, a virtualization device of a GPU is also provided in the embodiment of the present application. The principle of the device is similar to the virtualization method of the GPU provided by the second embodiment of the present application. See the implementation of the method, and the repetition will not be repeated.
实施例五 Embodiment 5
图7示出了根据本申请实施例五的GPU的虚拟化装置的结构示意图。FIG. 7 is a schematic structural diagram of a virtualization device of a GPU according to Embodiment 5 of the present application.
如图7所示,根据本申请实施例五的GPU的虚拟化装置700包括:获取模块701,用于通过共享内存获取来自第一操作系统的图形处理指令;执行模块702,用于在该第二操作系统处执行该图形处理指令,得到处理结果;显示模块703,用于将处理结果作为图形处理操作的响应进行显示;其中,图形处理操作是第一操作系统处接收到的;其中,该共享内存对该第一操作系统和第二操作系统均处于可读和可写状态。As shown in FIG. 7, the virtualization device 700 of the GPU according to Embodiment 5 of the present application includes: an obtaining module 701, configured to acquire a graphics processing instruction from a first operating system by using a shared memory; and an executing module 702, configured to: The operating system executes the graphics processing instruction to obtain a processing result; the display module 703 is configured to display the processing result as a response of the graphics processing operation; wherein the graphics processing operation is received by the first operating system; The shared memory is readable and writable for both the first operating system and the second operating system.
具体地,该第一操作系统可以为客Guest操作系统,该第二操作系统可以为主Host操作系统。Specifically, the first operating system may be a guest guest operating system, and the second operating system may be a host guest operating system.
具体地,获取模块,具体可以包括:第二地址接收子模块,用于接收来自第一操作系统的图形处理指令在共享内存的偏移地址;第二读取子模块,用于根据该图形处理指令在共享内存的偏移地址,从共享内存读取该图形处理指令。Specifically, the acquiring module may specifically include: a second address receiving submodule, configured to receive an offset address of the graphics processing instruction from the first operating system in the shared memory; and a second read submodule configured to process according to the graphic The instruction reads the graphics processing instruction from the shared memory at the offset address of the shared memory.
具体地,该图形处理指令可以包括图形处理函数和参数;第二读取子模块,具体可以用于:从共享内存的第一存储区读取该图形处理指令。Specifically, the graphics processing instruction may include a graphics processing function and a parameter; and the second reading sub-module may be specifically configured to: read the graphics processing instruction from the first storage area of the shared memory.
具体地,该图形处理指令还可以包括同步信息,该同步信息可以用于指示该第二操作系统执行该图形处理指令的时刻;执行模块,具体可以用于:在该同步信息指示的时刻,执行该图形处理指令。 Specifically, the graphics processing instruction may further include synchronization information, where the synchronization information may be used to indicate a time when the second operating system executes the graphics processing instruction, and the execution module may be configured to: execute at a time indicated by the synchronization information The graphics processing instructions.
具体地,该图形处理指令还可以包括图形内容数据;该共享内存还可以包括第二存储区;第二读取子模块,还可以用于:从共享内存的第二存储区读取该图形内容数据。Specifically, the graphics processing instruction may further include graphics content data; the shared memory may further include a second storage area; and the second reading submodule may be further configured to: read the graphic content from the second storage area of the shared memory data.
具体地,该第一存储区包括多个通道,其中,各通道对应于不同的线程;该装置还可以包括:第二确定模块,用于根据图形处理指令对应的线程,确定该图形处理指令对应的通道。Specifically, the first storage area includes a plurality of channels, wherein each channel corresponds to a different thread; the device may further include: a second determining module, configured to determine, according to the thread corresponding to the graphics processing instruction, the graphics processing instruction Channel.
具体地,该图形处理指令可以包括图形处理函数对应的编号和参数;第二读取子模块,具体可以用于:从该第一存储区读取该该图形处理函数编号和参数;根据该图形处理函数编号确定对应的图形处理函数。Specifically, the graphics processing instruction may include a number and a parameter corresponding to the graphics processing function; the second reading submodule may be specifically configured to: read the graphics processing function number and parameters from the first storage area; The processing function number determines the corresponding graphics processing function.
具体地,根据本申请实施例的GPU虚拟化装置还可以包括:第二传递模块,用于将执行结果,通过共享内存传递至第一操作系统。Specifically, the GPU virtualization apparatus according to the embodiment of the present application may further include: a second delivery module, configured to deliver the execution result to the first operating system through the shared memory.
具体地,第二传递模块,具体可以包括:第二写入子模块,用于将执行结果写入所述共享内存;第二发送子模块,用于将执行结果在共享内存的偏移地址发送至第一操作系统,以使第一操作系统根据处理结果在共享内存的偏移地址,获取执行结果。Specifically, the second delivery module may specifically include: a second write submodule, configured to write an execution result to the shared memory; and a second sending submodule, configured to send the execution result to an offset address of the shared memory Go to the first operating system, so that the first operating system obtains an execution result according to the offset result of the shared memory in the processing result.
采用本申请实施例中的GPU的虚拟化装置,在共享内存的基础上实现了OpenGL API的远程调用,从而实现GPU的虚拟化。With the virtualization device of the GPU in the embodiment of the present application, the remote call of the OpenGL API is implemented on the basis of the shared memory, thereby realizing the virtualization of the GPU.
基于同一发明构思,本申请实施例中还提供了一种GPU的虚拟化系统,由于该系统解决问题的原理与本申请实施例一和二所提供的GPU的虚拟化方法相似,因此该系统的实施可以参见方法的实施,重复之处不再赘述。Based on the same inventive concept, a virtualization system of a GPU is also provided in the embodiment of the present application. The principle of solving the problem is similar to the virtualization method of the GPU provided in Embodiments 1 and 2 of the present application. Implementation can refer to the implementation of the method, and the repetition will not be repeated.
实施例六Embodiment 6
图8示出了根据本申请实施例六的GPU的虚拟化系统的结构示意图。FIG. 8 is a schematic structural diagram of a virtualization system of a GPU according to Embodiment 6 of the present application.
如图8所示,根据本申请实施例六的GPU的虚拟化系统800包括:第一操作系统801,包括GPU的虚拟化装置600;共享内存802,用于存储来自该第一操作系统的图形操作指令和来自第二操作系统的处理结果;其中,该共 享内存对该第一操作系统和第二操作系统均处于可读和可写状态;第二操作系统803,包括GPU的虚拟化装置700。As shown in FIG. 8, the virtualization system 800 of the GPU according to Embodiment 6 of the present application includes: a first operating system 801, a virtualization device 600 including a GPU, and a shared memory 802 for storing graphics from the first operating system. Operation instructions and processing results from the second operating system; wherein, the total The memory is in a readable and writable state for both the first operating system and the second operating system; the second operating system 803 includes a virtualization device 700 of the GPU.
在具体实施时,第一操作系统801的实施可以参见本申请实施例一中第一操作系统201的实施,重复之处不再赘述。For the implementation of the first operating system 801, refer to the implementation of the first operating system 201 in the first embodiment of the present application, and details are not described herein again.
在具体实施时,共享内存802的实施可以参见本申请实施例一中共享内存203的实施,重复之处不再赘述。For the implementation of the shared memory 802, refer to the implementation of the shared memory 203 in the first embodiment of the present application, and details are not described herein again.
在具体实施时,第二操作系统803的实施可以参见本申请实施例一中第二操作系统202的实施,重复之处不再赘述。For the implementation of the second operating system 803, refer to the implementation of the second operating system 202 in the first embodiment of the present application, and details are not described herein again.
具体地,该第一操作系统可以为客Guest操作系统,该第二操作系统可以为主Host操作系统。Specifically, the first operating system may be a guest guest operating system, and the second operating system may be a host guest operating system.
采用本申请实施例中的GPU的虚拟化系统,在共享内存的基础上实现了OpenGL API的远程调用,从而实现GPU的虚拟化。With the virtualization system of the GPU in the embodiment of the present application, the remote call of the OpenGL API is implemented on the basis of the shared memory, thereby realizing the virtualization of the GPU.
实施例七Example 7
基于同一发明构思,本申请实施例中还提供了如图9所示的一种电子设备900。Based on the same inventive concept, an electronic device 900 as shown in FIG. 9 is also provided in the embodiment of the present application.
如图9所示,根据本申请实施例七的电子设备900包括:显示器901,存储器902,一个或多个处理器903;总线904;以及一个或多个模块,该一个或多个模块被存储在该存储器中,并被配置成由该一个或多个处理器执行,该一个或多个模块包括用于执行根据本申请实施例一中任一方法中各个步骤的指令。As shown in FIG. 9, an electronic device 900 according to Embodiment 7 of the present application includes: a display 901, a memory 902, one or more processors 903, a bus 904, and one or more modules, the one or more modules being stored In the memory, and configured to be executed by the one or more processors, the one or more modules include instructions for performing the steps in any of the methods of the first embodiment of the present application.
基于同一发明构思,本申请实施例中还提供了一种与包括显示器的电子设备900结合使用的计算机程序产品,该计算机程序产品包括计算机可读的存储介质和内嵌于其中的计算机程序机制,该计算机程序机制包括用于执行本申请实施例一中任一该方法中各个步骤的指令。Based on the same inventive concept, a computer program product for use in conjunction with an electronic device 900 including a display, the computer program product comprising a computer readable storage medium and a computer program mechanism embedded therein are also provided. The computer program mechanism includes instructions for performing the various steps of the method of any of the first embodiment of the present application.
实施例八 Example eight
基于同一发明构思,本申请实施例中还提供了如图10所示的一种电子设备1000。Based on the same inventive concept, an electronic device 1000 as shown in FIG. 10 is also provided in the embodiment of the present application.
如图10所示,根据本申请实施例八的电子设备1000包括:显示器1001,存储器1002,一个或多个处理器1003;总线1004以及一个或多个模块,该一个或多个模块被存储在该存储器中,并被配置成由该一个或多个处理器执行,该一个或多个模块包括用于执行根据本申请实施例二中任一方法中各个步骤的指令。As shown in FIG. 10, an electronic device 1000 according to Embodiment 8 of the present application includes: a display 1001, a memory 1002, one or more processors 1003, a bus 1004, and one or more modules, the one or more modules being stored in The memory is configured to be executed by the one or more processors, the one or more modules comprising instructions for performing the steps of any of the methods of the second embodiment of the present application.
基于同一发明构思,本申请实施例中还提供了一种与包括显示器的电子设备1000结合使用的计算机程序产品,该计算机程序产品包括计算机可读的存储介质和内嵌于其中的计算机程序机制,该计算机程序机制包括用于执行本申请实施例二中任一该方法中各个步骤的指令。Based on the same inventive concept, a computer program product for use in conjunction with an electronic device 1000 including a display, the computer program product comprising a computer readable storage medium and a computer program mechanism embedded therein are also provided. The computer program mechanism includes instructions for performing the various steps of the method of any of the second embodiment of the present application.
本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art will appreciate that embodiments of the present application can be provided as a method, system, or computer program product. Thus, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment in combination of software and hardware. Moreover, the application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) including computer usable program code.
本申请是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (system), and computer program products according to embodiments of the present application. It will be understood that each flow and/or block of the flowchart illustrations and/or FIG. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing device to produce a machine for the execution of instructions for execution by a processor of a computer or other programmable data processing device. Means for implementing the functions specified in one or more of the flow or in a block or blocks of the flow chart.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设 备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions can also be stored in a bootable computer or other programmable data processing device. In a computer readable memory that operates in a particular manner, causing instructions stored in the computer readable memory to produce an article of manufacture comprising an instruction device implemented in one or more flows and/or block diagrams of the flowchart The function specified in the box or in multiple boxes.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device. The instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow diagram.
尽管已描述了本申请的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例作出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本申请范围的所有变更和修改。While the preferred embodiment of the present application has been described, it will be apparent that those skilled in the art can make further changes and modifications to the embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and the modifications and
显然,本领域的技术人员可以对本申请进行各种改动和变型而不脱离本申请的精神和范围。这样,倘若本申请的这些修改和变型属于本申请权利要求及其等同技术的范围之内,则本申请也意图包含这些改动和变型在内。 It will be apparent to those skilled in the art that various modifications and changes can be made in the present application without departing from the spirit and scope of the application. Thus, it is intended that the present invention cover the modifications and variations of the present invention.

Claims (43)

  1. 一种图形处理器GPU的虚拟化方法,其特征在于,包括:A method for virtualizing a graphics processor GPU, comprising:
    接收在第一操作系统处的图形处理操作,并根据所述图形处理操作确定对应的图形处理指令;Receiving a graphics processing operation at the first operating system, and determining a corresponding graphics processing instruction according to the graphics processing operation;
    将所述图形处理指令通过共享内存传递至第二操作系统;其中,所述共享内存对所述第一操作系统和所述第二操作系统均处于可读和可写状态。Passing the graphics processing instructions to the second operating system through the shared memory; wherein the shared memory is in a readable and writable state for both the first operating system and the second operating system.
  2. 根据权利要求1所述的方法,其特征在于,将所述图形处理指令通过共享内存传递至所述第二操作系统,具体包括:The method according to claim 1, wherein the transferring the graphics processing instruction to the second operating system through the shared memory comprises:
    将所述图形处理指令写入至所述共享内存;Writing the graphics processing instruction to the shared memory;
    将所述图形处理指令在所述共享内存的偏移地址发送至所述第二操作系统。Transmitting the graphics processing instruction to the second operating system at an offset address of the shared memory.
  3. 根据权利要求2所述的方法,其特征在于,所述图形处理指令包括图形处理函数和参数;将所述图形处理指令写入至所述共享内存,具体包括:The method of claim 2, wherein the graphics processing instructions comprise graphics processing functions and parameters; and the writing of the graphics processing instructions to the shared memory comprises:
    将所述图形处理指令存储至所述共享内存的第一存储区。The graphics processing instructions are stored to a first memory area of the shared memory.
  4. 根据权利要求3所述的方法,其特征在于,所述图形处理指令还包括同步信息,所述同步信息用于指示所述第二操作系统执行所述图形处理指令的时刻。The method of claim 3 wherein said graphics processing instructions further comprise synchronization information for indicating a time at which said second operating system executes said graphics processing instructions.
  5. 根据权利要求3所述的方法,其特征在于,所述图形处理指令还包括图形内容数据;所述共享内存还包括第二存储区;将所述图形处理指令写入至所述共享内存,还包括:The method of claim 3, wherein the graphics processing instructions further comprise graphics content data; the shared memory further comprising a second memory area; writing the graphics processing instructions to the shared memory, further include:
    将所述图形内容数据写入至所述第二存储区。Writing the graphic content data to the second storage area.
  6. 根据权利要求5所述的方法,其特征在于,所述第二存储区包括多个块,其中,所述各块具有预先设置的大小,所述预先设置的大小适配于GPU图形内容数据;在将所述图形内容数据写入至所述第二存储区之前,还包括:The method according to claim 5, wherein the second storage area comprises a plurality of blocks, wherein the blocks have a preset size, and the preset size is adapted to GPU graphic content data; Before the writing of the graphic content data to the second storage area, the method further includes:
    根据所述图形内容数据的大小,确定所述图形内容数据对应的块。And determining, according to the size of the graphic content data, a block corresponding to the graphic content data.
  7. 根据权利要求3所述的方法,其特征在于,所述第一存储区包括多个 通道,其中,所述各通道对应于不同的线程;在所述图形处理指令写入至所述共享内存之前,还包括:The method of claim 3 wherein said first storage area comprises a plurality a channel, wherein each channel corresponds to a different thread; before the graphics processing instruction is written to the shared memory, the method further includes:
    根据所述图形处理指令对应的线程,确定所述图形处理指令对应的通道。Determining, according to the thread corresponding to the graphics processing instruction, a channel corresponding to the graphics processing instruction.
  8. 根据权利要求2所述的方法,其特征在于,所述图形处理指令包括图形处理函数对应的编号和参数;将所述图形处理指令写入至所述共享内存,具体包括:The method according to claim 2, wherein the graphics processing instruction includes a number and a parameter corresponding to the graphics processing function; and the writing the graphics processing instruction to the shared memory, specifically:
    确定所述图形处理函数对应的编号;Determining a number corresponding to the graphics processing function;
    将所述图形处理函数编号和参数写入至所述第一存储区。The graphics processing function number and parameters are written to the first memory area.
  9. 根据权利要求1所述的方法,其特征在于,还包括:接收来自所述第二操作系统的执行结果。The method of claim 1 further comprising receiving an execution result from said second operating system.
  10. 根据权利要求9所述的方法,其特征在于,接收来自所述第二操作系统的执行结果,具体包括:The method according to claim 9, wherein receiving the execution result from the second operating system comprises:
    接收来自所述第二操作系统的执行结果在所述共享内存的偏移地址;Receiving an offset address of the execution result from the second operating system in the shared memory;
    根据执行结果在所述共享内存的偏移地址,从所述共享内存读取所述执行结果。The execution result is read from the shared memory according to an execution result of the offset address of the shared memory.
  11. 一种GPU的虚拟化方法,其特征在于,包括:A method for virtualizing a GPU, comprising:
    通过共享内存获取来自第一操作系统的图形处理指令;Obtaining graphics processing instructions from the first operating system through the shared memory;
    在第二操作系统处执行所述图形处理指令,得到处理结果;Executing the graphics processing instruction at a second operating system to obtain a processing result;
    将所述处理结果作为图形处理操作的响应进行显示;其中,所述图形处理操作是在所述第一操作系统处接收到的;Displaying the result of the processing as a response to a graphics processing operation; wherein the graphics processing operation is received at the first operating system;
    其中,所述共享内存对所述第一操作系统和所述第二操作系统均处于可读和可写状态。The shared memory is in a readable and writable state for both the first operating system and the second operating system.
  12. 根据权利要求11所述的方法,其特征在于,通过共享内存获取来自第一操作系统的图形处理指令,具体包括:The method of claim 11, wherein the obtaining the graphics processing instruction from the first operating system by using the shared memory comprises:
    接收来自第一操作系统的图形处理指令在共享内存的偏移地址; Receiving an offset address of the graphics processing instruction from the first operating system in the shared memory;
    根据所述图形处理指令在共享内存的偏移地址,从共享内存读取所述图形处理指令。The graphics processing instruction is read from the shared memory according to the offset address of the shared memory in the graphics processing instruction.
  13. 根据权利要求12所述的方法,其特征在于,所述图形处理指令包括图形处理函数和参数;从共享内存读取所述图形处理指令,具体包括:The method according to claim 12, wherein the graphics processing instruction comprises a graphics processing function and a parameter; and the reading the graphics processing instruction from the shared memory comprises:
    从共享内存的第一存储区读取所述图形处理指令。The graphics processing instructions are read from a first memory area of the shared memory.
  14. 根据权利要求13所述的方法,其特征在于,所述图形处理指令还包括同步信息,所述同步信息用于指示所述第二操作系统执行所述图形处理指令的时刻;在所述第二操作系统处执行所述图形处理指令,具体包括:The method according to claim 13, wherein said graphics processing instruction further comprises synchronization information, said synchronization information being used to indicate a time at which said second operating system executes said graphics processing instruction; The graphic processing instruction is executed by the operating system, and specifically includes:
    在所述同步信息指示的时刻,执行所述图形处理指令。The graphics processing instruction is executed at the timing indicated by the synchronization information.
  15. 根据权利要求13所述的方法,其特征在于,所述图形处理指令还包括图形内容数据;所述共享内存还包括第二存储区;从共享内存读取所述图形处理指令,还包括:The method according to claim 13, wherein the graphics processing instruction further comprises graphic content data; the shared memory further comprises a second storage area; and the reading the graphics processing instruction from the shared memory, further comprising:
    从共享内存的第二存储区读取所述图形内容数据。The graphic content data is read from a second storage area of the shared memory.
  16. 根据权利要求13所述的方法,其特征在于,所述第一存储区包括多个通道,其中,所述各通道对应于不同的线程;在从共享内存读取所述图形处理指令之前,还包括:The method of claim 13 wherein said first storage area comprises a plurality of channels, wherein said each channel corresponds to a different thread; prior to reading said graphics processing instructions from said shared memory, include:
    根据所述图形处理指令对应的线程,确定所述图形处理指令对应的通道。Determining, according to the thread corresponding to the graphics processing instruction, a channel corresponding to the graphics processing instruction.
  17. 根据权利要求12所述的方法,其特征在于,所述图形处理指令包括图形处理函数对应的编号和参数;从共享内存的第一存储区读取所述图形处理指令,具体包括:The method according to claim 12, wherein the graphics processing instruction includes a number and a parameter corresponding to the graphics processing function; and the reading the graphics processing instruction from the first storage area of the shared memory, specifically:
    从所述第一存储区读取所述所述图形处理函数编号和参数;Reading the graphics processing function number and parameters from the first storage area;
    根据所述图形处理函数编号确定对应的图形处理函数。A corresponding graphics processing function is determined according to the graphics processing function number.
  18. 根据权利要求11所述的方法,其特征在于,还包括:The method of claim 11 further comprising:
    将执行结果通过共享内存传递至所述第一操作系统。The execution result is passed to the first operating system through the shared memory.
  19. 根据权利要求18所述的方法,其特征在于,将执行结果通过共享内存 传递至所述第一操作系统,具体包括:The method of claim 18, wherein the execution result is passed through the shared memory Passed to the first operating system, specifically:
    将执行结果写入所述共享内存;Write the execution result to the shared memory;
    将所述执行结果在所述共享内存的偏移地址发送至所述第一操作系统,以使第一操作系统根据所述处理结果在所述共享内存的偏移地址,获取所述执行结果。Transmitting the execution result to the first operating system at an offset address of the shared memory, so that the first operating system acquires the execution result according to the processing result in an offset address of the shared memory.
  20. 一种GPU的虚拟化装置,其特征在于,包括:A GPU virtualization device, comprising:
    第一接收模块,用于接收在第一操作系统处的图形处理操作,并根据所述图形处理操作确定对应的图形操作指令;a first receiving module, configured to receive a graphics processing operation at the first operating system, and determine a corresponding graphics operation instruction according to the graphics processing operation;
    第一传递模块,用于将所述图形处理指令通过共享内存传递至所述第二操作系统;其中,所述共享内存对所述第一操作系统和第二操作系统均处于可读和可写状态。a first delivery module, configured to deliver the graphics processing instruction to the second operating system through a shared memory; wherein the shared memory is readable and writable to both the first operating system and the second operating system status.
  21. 根据权利要求20所述的装置,其特征在于,第一传递模块,具体包括:The device according to claim 20, wherein the first delivery module comprises:
    第一写入子模块,将所述图形处理指令写入至所述共享内存;a first write submodule, writing the graphics processing instruction to the shared memory;
    第一发送子模块,用于将所述图形处理指令在所述共享内存的偏移地址发送至所述第二操作系统。And a first sending submodule, configured to send the graphics processing instruction to the second operating system at an offset address of the shared memory.
  22. 根据权利要求21所述的装置,其特征在于,所述图形处理指令包括图形处理函数和参数;第一写入子模块,具体用于:The device according to claim 21, wherein the graphics processing instruction comprises a graphics processing function and a parameter; and the first writing sub-module is specifically configured to:
    将所述图形处理指令存储至所述共享内存的第一存储区。The graphics processing instructions are stored to a first memory area of the shared memory.
  23. 根据权利要求22所述的装置,其特征在于,所述图形处理指令还包括同步信息,所述同步信息用于指示所述第二操作系统执行所述图形处理指令的时刻。The apparatus of claim 22, wherein the graphics processing instructions further comprise synchronization information for indicating a time at which the second operating system executes the graphics processing instructions.
  24. 根据权利要求22所述的装置,其特征在于,所述图形处理指令还包括图形内容数据;所述共享内存还包括第二存储区;第一写入子模块,还用于:The device according to claim 22, wherein the graphics processing instruction further comprises graphic content data; the shared memory further comprises a second storage area; the first writing sub-module is further configured to:
    将所述图形内容数据写入至所述第二存储区。Writing the graphic content data to the second storage area.
  25. 根据权利要求24所述的装置,其特征在于,所述第二存储区包括多个块,其中,所述各块具有预先设置的大小,所述预先设置的大小适配于GPU 图形内容数据;所述装置还包括:The apparatus according to claim 24, wherein said second storage area comprises a plurality of blocks, wherein said each block has a preset size, said preset size being adapted to a GPU Graphic content data; the device further includes:
    第一确定模块,用于根据所述图形内容数据的大小,确定所述图形内容数据对应的块。The first determining module is configured to determine, according to the size of the graphic content data, a block corresponding to the graphic content data.
  26. 根据权利要求22所述的装置,其特征在于,所述第一存储区包括多个通道,其中,所述各通道对应于不同的线程;所述装置还包括:The device according to claim 22, wherein the first storage area comprises a plurality of channels, wherein each of the channels corresponds to a different thread; the device further comprises:
    第二确定模块,用于根据所述图形处理指令对应的线程,确定所述图形处理指令对应的通道。The second determining module is configured to determine, according to the thread corresponding to the graphics processing instruction, a channel corresponding to the graphics processing instruction.
  27. 根据权利要求21所述的装置,其特征在于,所述图形处理指令包括图形处理函数对应的编号和参数;第一写入子模块,具体用于:The device according to claim 21, wherein the graphics processing instruction includes a number and a parameter corresponding to the graphics processing function; and the first writing sub-module is specifically configured to:
    确定所述图形处理函数对应的编号;Determining a number corresponding to the graphics processing function;
    将所述图形处理函数编号和参数写入至所述第一存储区。The graphics processing function number and parameters are written to the first memory area.
  28. 根据权利要求20所述的装置,其特征在于,还包括:第二接收模块,用于接收来自所述第二操作系统的执行结果。The apparatus according to claim 20, further comprising: a second receiving module, configured to receive an execution result from the second operating system.
  29. 根据权利要求28所述的装置,其特征在于,所述第二接收模块,具体包括:The device according to claim 28, wherein the second receiving module specifically includes:
    第一地址接收子模块,用于接收来自所述第二操作系统的执行结果在所述共享内存的偏移地址;a first address receiving submodule, configured to receive an offset address of the execution result from the second operating system in the shared memory;
    第一读取子模块,用于根据执行结果在所述共享内存的偏移地址,从所述共享内存读取所述执行结果。And a first reading submodule, configured to read the execution result from the shared memory according to an execution result of the offset address of the shared memory.
  30. 一种GPU的虚拟化装置,其特征在于,包括:A GPU virtualization device, comprising:
    获取模块,用于通过共享内存获取来自第一操作系统的图形处理指令;Obtaining a module, configured to acquire a graphics processing instruction from the first operating system by using the shared memory;
    执行模块,用于在所述第二操作系统处执行所述图形处理指令,得到处理结果;An execution module, configured to execute the graphics processing instruction at the second operating system, to obtain a processing result;
    显示模块,用于将所述处理结果作为图形处理操作的响应进行显示;其中,所述图形处理操作是所述第一操作系统处接收到的;其中,所述共享内存对所述第一操作系统和第二操作系统均处于可读和可写状态。 a display module, configured to display the processing result as a response of a graphics processing operation; wherein the graphics processing operation is received by the first operating system; wherein the shared memory is to the first operation Both the system and the second operating system are in a readable and writable state.
  31. 根据权利要求30所述的装置,其特征在于,获取模块,具体包括:The device according to claim 30, wherein the acquiring module comprises:
    第二地址接收子模块,用于接收来自第一操作系统的图形处理指令在共享内存的偏移地址;a second address receiving submodule, configured to receive an offset address of the graphics processing instruction from the first operating system in the shared memory;
    第二读取子模块,用于根据所述图形处理指令在共享内存的偏移地址,从共享内存读取所述图形处理指令。And a second reading submodule, configured to read the graphics processing instruction from the shared memory according to the offset address of the shared memory in the graphics processing instruction.
  32. 根据权利要求31所述的装置,其特征在于,所述图形处理指令包括图形处理函数和参数;第二读取子模块,具体用于:The device according to claim 31, wherein the graphics processing instruction comprises a graphics processing function and a parameter; and the second reading sub-module is specifically configured to:
    从共享内存的第一存储区读取所述图形处理指令。The graphics processing instructions are read from a first memory area of the shared memory.
  33. 根据权利要求32所述的装置,其特征在于,所述图形处理指令还包括同步信息,所述同步信息用于指示所述第二操作系统执行所述图形处理指令的时刻;执行模块,具体用于:The apparatus according to claim 32, wherein the graphics processing instruction further comprises synchronization information, wherein the synchronization information is used to indicate a time when the second operating system executes the graphics processing instruction; and an execution module, specifically to:
    在所述同步信息指示的时刻,执行所述图形处理指令。The graphics processing instruction is executed at the timing indicated by the synchronization information.
  34. 根据权利要求32所述的装置,其特征在于,所述图形处理指令还包括图形内容数据;所述共享内存还包括第二存储区;第二读取子模块,还用于:The device according to claim 32, wherein the graphics processing instruction further comprises graphic content data; the shared memory further comprises a second storage area; and the second reading sub-module is further configured to:
    从共享内存的第二存储区读取所述图形内容数据。The graphic content data is read from a second storage area of the shared memory.
  35. 根据权利要求32所述的装置,其特征在于,所述第一存储区包括多个通道,其中,所述各通道对应于不同的线程;所述装置还包括:The device according to claim 32, wherein the first storage area comprises a plurality of channels, wherein each of the channels corresponds to a different thread; the device further comprises:
    第二确定模块,用于所述图形处理指令对应的线程,确定所述图形处理指令对应的通道。The second determining module is configured to: determine, by the thread corresponding to the graphics processing instruction, a channel corresponding to the graphics processing instruction.
  36. 根据权利要求31所述的装置,其特征在于,所述图形处理指令包括图形处理函数对应的编号和参数;第二读取子模块,具体用于:The device according to claim 31, wherein the graphics processing instruction comprises a number and a parameter corresponding to the graphics processing function; and the second reading sub-module is specifically configured to:
    从所述第一存储区读取所述所述图形处理函数编号和参数;Reading the graphics processing function number and parameters from the first storage area;
    根据所述图形处理函数编号确定对应的图形处理函数。A corresponding graphics processing function is determined according to the graphics processing function number.
  37. 根据权利要求30所述的装置,其特征在于,还包括:The device of claim 30, further comprising:
    第二传递模块,用于将执行结果,通过共享内存传递至所述第一操作系统。 And a second delivery module, configured to pass the execution result to the first operating system through the shared memory.
  38. 根据权利要求37所述的装置,其特征在于,第二传递模块,具体包括:The device according to claim 37, wherein the second delivery module comprises:
    第二写入子模块,用于将执行结果写入所述共享内存;a second write submodule, configured to write an execution result to the shared memory;
    第二发送子模块,用于将所述执行结果在所述共享内存的偏移地址发送至所述第一操作系统,以使第一操作系统根据所述处理结果在所述共享内存的偏移地址,获取所述执行结果。a second sending submodule, configured to send the execution result to the first operating system at an offset address of the shared memory, so that the first operating system offsets the shared memory according to the processing result Address to obtain the execution result.
  39. 一种GPU的虚拟化系统,其特征在于,包括:A GPU virtualization system, comprising:
    第一操作系统,包括如权利要求20至29中任一项所述的GPU的虚拟化装置;a first operating system, comprising the virtualization device of the GPU of any one of claims 20 to 29;
    共享内存,用于存储来自所述第一操作系统的图形操作指令和来自第二操作系统的处理结果;其中,所述共享内存对所述第一操作系统和第二操作系统均处于可读和可写状态;a shared memory for storing graphics operation instructions from the first operating system and processing results from a second operating system; wherein the shared memory is readable and readable by both the first operating system and the second operating system Writable state
    第二操作系统,包括如权利要求30至38中任一项所述的GPU的虚拟化装置。A second operating system comprising the virtualization device of the GPU of any one of claims 30 to 38.
  40. 一种电子设备,其特征在于,所述电子设备包括:显示器,存储器,一个或多个处理器;以及一个或多个模块,所述一个或多个模块被存储在所述存储器中,并被配置成由所述一个或多个处理器执行,所述一个或多个模块包括用于执行权利要求1-10中任一所述方法中各个步骤的指令。An electronic device, comprising: a display, a memory, one or more processors; and one or more modules, the one or more modules being stored in the memory and being Configured to be executed by the one or more processors, the one or more modules comprising instructions for performing the various steps of the method of any of claims 1-10.
  41. 一种电子设备,其特征在于,所述电子设备包括:显示器,存储器,一个或多个处理器;以及一个或多个模块,所述一个或多个模块被存储在所述存储器中,并被配置成由所述一个或多个处理器执行,所述一个或多个模块包括用于执行权利要求11-19中任一所述方法中各个步骤的指令。An electronic device, comprising: a display, a memory, one or more processors; and one or more modules, the one or more modules being stored in the memory and being Configured to be executed by the one or more processors, the one or more modules comprising instructions for performing the various steps of the method of any of claims 11-19.
  42. 一种与包括显示器的电子设备结合使用的计算机程序产品,所述计算机程序产品包括计算机可读的存储介质和内嵌于其中的计算机程序机制,所述计算机程序机制包括用于执行权利要求1-10中任一所述方法中各个步骤的指令。A computer program product for use with an electronic device including a display, the computer program product comprising a computer readable storage medium and a computer program mechanism embedded therein, the computer program mechanism comprising for performing claim 1 The instructions of the various steps in any of the methods described in 10.
  43. 一种与包括显示器的电子设备结合使用的计算机程序产品,所述计算 机程序产品包括计算机可读的存储介质和内嵌于其中的计算机程序机制,所述计算机程序机制包括用于执行权利要求11-19中任一所述方法中各个步骤的指令。 A computer program product for use with an electronic device including a display, the calculation The machine program product comprises a computer readable storage medium and a computer program mechanism embodied therein, the computer program mechanism comprising instructions for performing the various steps of the method of any of claims 11-19.
PCT/CN2016/113260 2016-12-29 2016-12-29 Gpu virtualization method, device, system, and electronic apparatus, and computer program product WO2018119951A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201680002845.1A CN107003892B (en) 2016-12-29 2016-12-29 GPU virtualization method, device and system, electronic equipment and computer program product
PCT/CN2016/113260 WO2018119951A1 (en) 2016-12-29 2016-12-29 Gpu virtualization method, device, system, and electronic apparatus, and computer program product

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2016/113260 WO2018119951A1 (en) 2016-12-29 2016-12-29 Gpu virtualization method, device, system, and electronic apparatus, and computer program product

Publications (1)

Publication Number Publication Date
WO2018119951A1 true WO2018119951A1 (en) 2018-07-05

Family

ID=59431118

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/113260 WO2018119951A1 (en) 2016-12-29 2016-12-29 Gpu virtualization method, device, system, and electronic apparatus, and computer program product

Country Status (2)

Country Link
CN (1) CN107003892B (en)
WO (1) WO2018119951A1 (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111114320A (en) * 2019-12-27 2020-05-08 深圳市众鸿科技股份有限公司 Vehicle-mounted intelligent cabin sharing display method and system
CN112925737A (en) * 2021-03-30 2021-06-08 上海西井信息科技有限公司 PCI heterogeneous system data fusion method, system, equipment and storage medium
CN113793246A (en) * 2021-11-16 2021-12-14 北京壁仞科技开发有限公司 Method and device for using graphics processor resources and electronic equipment
CN115344226A (en) * 2022-10-20 2022-11-15 亿咖通(北京)科技有限公司 Screen projection method, device, equipment and medium under virtualization management
CN116485628A (en) * 2023-06-15 2023-07-25 摩尔线程智能科技(北京)有限责任公司 Image display method, device and system

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107436797A (en) * 2017-08-14 2017-12-05 深信服科技股份有限公司 A kind of director data processing method and processing device based on virtualized environment
WO2019127476A1 (en) * 2017-12-29 2019-07-04 深圳前海达闼云端智能科技有限公司 Virtual system bluetooth communication method and device, virtual system, storage medium, and electronic apparatus
CN109542829B (en) * 2018-11-29 2023-04-25 北京元心科技有限公司 Control method and device of GPU (graphics processing Unit) equipment in multiple systems and electronic equipment
CN110442389B (en) * 2019-08-07 2024-01-09 北京技德系统技术有限公司 Method for sharing GPU (graphics processing Unit) in multi-desktop environment
CN111522670A (en) * 2020-05-09 2020-08-11 中瓴智行(成都)科技有限公司 GPU virtualization method, system and medium for Android system
CN112581650A (en) * 2020-11-12 2021-03-30 江苏北斗星通汽车电子有限公司 Video data processing method and device based on intelligent cabin and electronic terminal
CN114579072A (en) * 2022-03-02 2022-06-03 南京芯驰半导体科技有限公司 Display screen projection method and device across multiple operating systems
CN115686748B (en) * 2022-10-26 2023-11-17 亿咖通(湖北)技术有限公司 Service request response method, device, equipment and medium under virtualization management
CN115775199B (en) * 2022-11-23 2024-04-16 海光信息技术股份有限公司 Data processing method and device, electronic equipment and computer readable storage medium
CN116597025B (en) * 2023-04-24 2023-09-26 北京麟卓信息科技有限公司 Compressed texture decoding optimization method based on heterogeneous instruction penetration
CN116243872B (en) * 2023-05-12 2023-07-21 南京砺算科技有限公司 Private memory allocation addressing method and device, graphics processor and medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102541618A (en) * 2010-12-29 2012-07-04 中国移动通信集团公司 Implementation method, system and device for virtualization of universal graphic processor
US20140229935A1 (en) * 2013-02-11 2014-08-14 Nvidia Corporation Virtual interrupt delivery from a graphics processing unit (gpu) of a computing system without hardware support therefor
CN104503731A (en) * 2014-12-15 2015-04-08 柳州职业技术学院 Quick identification method for binary image connected domain marker
CN104754464A (en) * 2013-12-31 2015-07-01 华为技术有限公司 Audio playing method, terminal and system
CN105487915A (en) * 2015-11-24 2016-04-13 上海君是信息科技有限公司 Sending delay mechanism based GPU virtualization performance improvement method

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100417077C (en) * 2002-10-11 2008-09-03 中兴通讯股份有限公司 Method for storage area management with static and dynamic joint
KR100592105B1 (en) * 2005-03-25 2006-06-21 엠텍비젼 주식회사 Method for controlling access to partitioned blocks of shared memory and portable terminal having shared memory
US8463980B2 (en) * 2010-09-30 2013-06-11 Microsoft Corporation Shared memory between child and parent partitions
US9047686B2 (en) * 2011-02-10 2015-06-02 Qualcomm Incorporated Data storage address assignment for graphics processing

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102541618A (en) * 2010-12-29 2012-07-04 中国移动通信集团公司 Implementation method, system and device for virtualization of universal graphic processor
US20140229935A1 (en) * 2013-02-11 2014-08-14 Nvidia Corporation Virtual interrupt delivery from a graphics processing unit (gpu) of a computing system without hardware support therefor
CN104754464A (en) * 2013-12-31 2015-07-01 华为技术有限公司 Audio playing method, terminal and system
CN104503731A (en) * 2014-12-15 2015-04-08 柳州职业技术学院 Quick identification method for binary image connected domain marker
CN105487915A (en) * 2015-11-24 2016-04-13 上海君是信息科技有限公司 Sending delay mechanism based GPU virtualization performance improvement method

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111114320A (en) * 2019-12-27 2020-05-08 深圳市众鸿科技股份有限公司 Vehicle-mounted intelligent cabin sharing display method and system
CN112925737A (en) * 2021-03-30 2021-06-08 上海西井信息科技有限公司 PCI heterogeneous system data fusion method, system, equipment and storage medium
CN112925737B (en) * 2021-03-30 2022-08-05 上海西井信息科技有限公司 PCI heterogeneous system data fusion method, system, equipment and storage medium
CN113793246A (en) * 2021-11-16 2021-12-14 北京壁仞科技开发有限公司 Method and device for using graphics processor resources and electronic equipment
CN113793246B (en) * 2021-11-16 2022-02-18 北京壁仞科技开发有限公司 Method and device for using graphics processor resources and electronic equipment
CN115344226A (en) * 2022-10-20 2022-11-15 亿咖通(北京)科技有限公司 Screen projection method, device, equipment and medium under virtualization management
CN115344226B (en) * 2022-10-20 2023-03-24 亿咖通(北京)科技有限公司 Screen projection method, device, equipment and medium under virtualization management
CN116485628A (en) * 2023-06-15 2023-07-25 摩尔线程智能科技(北京)有限责任公司 Image display method, device and system
CN116485628B (en) * 2023-06-15 2023-12-29 摩尔线程智能科技(北京)有限责任公司 Image display method, device and system

Also Published As

Publication number Publication date
CN107003892B (en) 2021-10-08
CN107003892A (en) 2017-08-01

Similar Documents

Publication Publication Date Title
WO2018119951A1 (en) Gpu virtualization method, device, system, and electronic apparatus, and computer program product
CN107077377B (en) Equipment virtualization method, device and system, electronic equipment and computer program product
US10310879B2 (en) Paravirtualized virtual GPU
TWI475488B (en) Virtual machine system, virtualization method and machine-readable medium containing instructions for virtualization
US9798565B2 (en) Data processing system and method having an operating system that communicates with an accelerator independently of a hypervisor
JP5620506B2 (en) Application image display method and apparatus
EP1691287A1 (en) Information processing device, process control method, and computer program
US20140359613A1 (en) Physical/virtual device failover with a shared backend
US11204790B2 (en) Display method for use in multi-operating systems and electronic device
CN107077376B (en) Frame buffer implementation method and device, electronic equipment and computer program product
US10002016B2 (en) Configuration of virtual machines in view of response time constraints
US20220050795A1 (en) Data processing method, apparatus, and device
CN113419845A (en) Calculation acceleration method and device, calculation system, electronic equipment and computer readable storage medium
US10467078B2 (en) Crash dump extraction of guest failure
WO2017045272A1 (en) Virtual machine migration method and device
CN114138423A (en) Virtualization construction system and method based on domestic GPU (graphics processing Unit) display card
EP3850479B1 (en) Virtual machine update while keeping devices attached to the virtual machine
Park et al. Virtualizing graphics architecture of android mobile platforms in KVM/ARM environment
US11954534B2 (en) Scheduling in a container orchestration system utilizing hardware topology hints
US20210133914A1 (en) Multiple o/s virtual video platform
CN117331704B (en) Graphics processor GPU scheduling method, device and storage medium
Lee VAR: Vulkan API Remoting for GPU-accelerated Rendering and Computation in Virtual Machines
CN115904617A (en) GPU virtualization implementation method based on SR-IOV technology

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 16925946

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 25.10.2019)

122 Ep: pct application non-entry in european phase

Ref document number: 16925946

Country of ref document: EP

Kind code of ref document: A1