GPU: add os traits for GPU - API

Some GPUs (and vGPUs on them) support different APIs or features.
This commit is to define os traits for APIs so that the resource
providers for GPUs or vGPUs can be characterised and can be
scheduled basing on different API traits.

Change-Id: I27b80ad3fba04ef02ce9619111353702de450600
This commit is contained in:
jianghua wang 2017-05-19 06:51:51 +01:00
parent 5baa0f6170
commit 1db10152fb
3 changed files with 89 additions and 0 deletions

View File

87
os_traits/hw/gpu/api.py Normal file
View File

@ -0,0 +1,87 @@
# -*- coding: utf-8 -*-
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
TRAITS = [
# ref: https://en.wikipedia.org/wiki/DirectX
'DIRECTX_V10',
'DIRECTX_V11',
'DIRECTX_V12',
# ref: https://en.wikipedia.org/wiki/Direct2D
'DIRECT2D',
# ref: https://en.wikipedia.org/wiki/Direct3D
'DIRECT3D_V6_0',
'DIRECT3D_V7_0',
'DIRECT3D_V8_0',
'DIRECT3D_V8_1',
'DIRECT3D_V9_0',
'DIRECT3D_V9_0B',
'DIRECT3D_V9_0C',
'DIRECT3D_V9_0L',
'DIRECT3D_V10_0',
'DIRECT3D_V10_1',
'DIRECT3D_V11_0',
'DIRECT3D_V11_1',
'DIRECT3D_V11_2',
'DIRECT3D_V11_3',
'DIRECT3D_V12_0',
# ref: https://en.wikipedia.org/wiki/Vulkan_(API)
'VULKAN',
# ref: https://en.wikipedia.org/wiki/DirectX_Video_Acceleration
'DXVA',
# ref: https://en.wikipedia.org/wiki/OpenCL
'OPENCL_V1_0',
'OPENCL_V1_1',
'OPENCL_V1_2',
'OPENCL_V2_0',
'OPENCL_V2_1',
'OPENCL_V2_2',
# ref: https://en.wikipedia.org/wiki/OpenGL
'OPENGL_V1_1',
'OPENGL_V1_2',
'OPENGL_V1_3',
'OPENGL_V1_4',
'OPENGL_V1_5',
'OPENGL_V2_0',
'OPENGL_V2_1',
'OPENGL_V3_0',
'OPENGL_V3_1',
'OPENGL_V3_2',
'OPENGL_V3_3',
'OPENGL_V4_0',
'OPENGL_V4_1',
'OPENGL_V4_2',
'OPENGL_V4_3',
'OPENGL_V4_4',
'OPENGL_V4_5',
# ref: https://en.wikipedia.org/wiki/CUDA
'CUDA_V1_0',
'CUDA_V1_1',
'CUDA_V1_2',
'CUDA_V1_3',
'CUDA_V2_0',
'CUDA_V2_1',
'CUDA_V3_0',
'CUDA_V3_2',
'CUDA_V3_5',
'CUDA_V3_7',
'CUDA_V5_0',
'CUDA_V5_2',
'CUDA_V5_3',
'CUDA_V6_0',
'CUDA_V6_1',
'CUDA_V6_2',
'CUDA_V7_0',
'CUDA_V7_1',
]

View File

@ -16,6 +16,7 @@ import re
import os_traits as ot
from os_traits.hw.cpu import x86
from os_traits.hw.gpu import api
from os_traits.hw.nic import offload
from os_traits.tests import base
@ -31,6 +32,7 @@ class TestSymbols(base.TestCase):
# And the "leaf-module" namespace...
self.assertEqual(x86.SSE42, ot.HW_CPU_X86_SSE42)
self.assertEqual(api.DIRECTX_V10, ot.HW_GPU_API_DIRECTX_V10)
self.assertEqual(offload.TSO, ot.HW_NIC_OFFLOAD_TSO)
def test_get_traits(self):