From c0c09551781f75dbb394b32771837e80d91ad4a4 Mon Sep 17 00:00:00 2001 From: Maryam Babaie Date: Wed, 30 Oct 2024 12:23:21 -0700 Subject: [PATCH] dev-amdgpu: Adding support for avs extended states and features. --- src/python/gem5/prebuilt/viper/board.py | 38 +++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/python/gem5/prebuilt/viper/board.py b/src/python/gem5/prebuilt/viper/board.py index 10eb57d5e5..2bf8869b92 100644 --- a/src/python/gem5/prebuilt/viper/board.py +++ b/src/python/gem5/prebuilt/viper/board.py @@ -34,6 +34,8 @@ from typing import ( Optional, ) +from m5.util import warn + from ...components.boards.abstract_board import AbstractBoard from ...components.boards.kernel_disk_workload import KernelDiskWorkload from ...components.boards.x86_board import X86Board @@ -83,6 +85,42 @@ class ViperBoard(X86Board): for gpu in self._gpus: gpu.connectGPU(self) + self.workload.enable_osxsave = 1 + # These values are taken from a real CPU and are further explained here: + # https://sandpile.org/x86/cpuid.htm#level_0000_000Dh + avx_extended_state = [ + 0x00000007, + 0x00000340, + 0x00000000, + 0x00000340, + 0x00000000, + 0x00000340, + 0x00000000, + 0x00000000, + 0x00000100, + 0x00000240, + 0x00000000, + 0x00000040, + 0x00000000, + 0x00000000, + 0x00000000, + 0x00000000, + ] + + # This modifies the default value for ECX only (4th in this array). + # See: https://sandpile.org/x86/cpuid.htm#level_0000_0001h + # Enables AVX, OSXSAVE, XSAVE, POPCNT, SSE4.2, SSE4.1, CMPXCHG16B, + # and FMA. + avx_cpu_features = [0x00020F51, 0x00000805, 0xEFDBFBFF, 0x1C803209] + for core_wrapper in self.get_processor().get_cores(): + if not core_wrapper.is_kvm_core(): + warn("AVX is only supported with KVM cores") + core = core_wrapper.get_simobject() + for isa in core.isa: + isa.vendor_string = "AuthenticAMD" + isa.ExtendedState = avx_extended_state + isa.FamilyModelStepping = avx_cpu_features + @overrides(KernelDiskWorkload) def get_disk_device(self): return "/dev/sda"