From 1db10152fbea53e09be1986c1bfed2bb9b05e58d Mon Sep 17 00:00:00 2001 From: jianghua wang Date: Fri, 19 May 2017 06:51:51 +0100 Subject: [PATCH] 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 --- os_traits/hw/gpu/__init__.py | 0 os_traits/hw/gpu/api.py | 87 +++++++++++++++++++++++++++++++ os_traits/tests/test_os_traits.py | 2 + 3 files changed, 89 insertions(+) create mode 100644 os_traits/hw/gpu/__init__.py create mode 100644 os_traits/hw/gpu/api.py diff --git a/os_traits/hw/gpu/__init__.py b/os_traits/hw/gpu/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/os_traits/hw/gpu/api.py b/os_traits/hw/gpu/api.py new file mode 100644 index 0000000..6d1e82f --- /dev/null +++ b/os_traits/hw/gpu/api.py @@ -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', +] diff --git a/os_traits/tests/test_os_traits.py b/os_traits/tests/test_os_traits.py index 5d3406f..db7b5fd 100644 --- a/os_traits/tests/test_os_traits.py +++ b/os_traits/tests/test_os_traits.py @@ -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):