From 0fbf4037873143b413375526230f5a2ff2fcb818 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Fri, 22 Sep 2023 14:22:35 -0700 Subject: [PATCH] Adds back in host testharnessrunner CI Necessary for asm tests to still run in the host "core". Useful for ensuring correct behaviour of our assembly tests. --- .github/workflows/hostrunner.yml | 107 ++++++++++++++++++ CMakeLists.txt | 1 - FEXCore/CMakeLists.txt | 1 - .../Source/Interface/Core/HostFeatures.cpp | 56 ++++++++- unittests/32Bit_ASM/CMakeLists.txt | 18 +-- unittests/ASM/CMakeLists.txt | 24 ++-- 6 files changed, 186 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/hostrunner.yml diff --git a/.github/workflows/hostrunner.yml b/.github/workflows/hostrunner.yml new file mode 100644 index 000000000..2e9149db1 --- /dev/null +++ b/.github/workflows/hostrunner.yml @@ -0,0 +1,107 @@ +name: Hostrunner tests + +on: + push: + branches: + - main + pull_request: + branches: + - main + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + CC: clang + CXX: clang++ + FEX_ENABLEAVX: 1 + +jobs: + build: + runs-on: ${{ matrix.arch }} + strategy: + matrix: + arch: [[self-hosted, x64]] + fail-fast: false + + steps: + - uses: actions/checkout@v3 + + - name: Set runner label + run: echo "runner_label=${{ matrix.arch[1] }}" >> $GITHUB_ENV + + - name: Set rootfs paths + run: | + echo "FEX_ROOTFS_MOUNT=/mnt/AutoNFS/rootfs/" >> $GITHUB_ENV + echo "FEX_ROOTFS_PATH=$HOME/Rootfs/" >> $GITHUB_ENV + echo "FEX_ROOTFS=$HOME/Rootfs/" >> $GITHUB_ENV + echo "ROOTFS=$HOME/Rootfs/" >> $GITHUB_ENV + + - name: Update RootFS cache + # Use a bash shell so we can use the same syntax for environment variable + # access regardless of the host operating system + shell: bash + run: $GITHUB_WORKSPACE/Scripts/CI_FetchRootFS.py + + - name : submodule checkout + # Need to update submodules + run: | + git submodule sync --recursive + git submodule update --init --depth 1 + + - name: Clean Build Environment + run: rm -Rf ${{runner.workspace}}/build + + - name: Create Build Environment + # Some projects don't allow in-source building, so create a separate build directory + # We'll use this as our working directory for all subsequent commands + run: cmake -E make_directory ${{runner.workspace}}/build + + - name: Configure CMake + # Use a bash shell so we can use the same syntax for environment variable + # access regardless of the host operating system + shell: bash + working-directory: ${{runner.workspace}}/build + # Note the current convention is to use the -S and -B options here to specify source + # and build directories, but this is only available with CMake 3.13 and higher. + # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 + run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -G Ninja -DENABLE_LTO=False -DENABLE_ASSERTIONS=True -DENABLE_X86_HOST_DEBUG=True + + - name: Build + working-directory: ${{runner.workspace}}/build + shell: bash + # Execute the build. You can specify a specific target with "--target " + run: cmake --build . --config $BUILD_TYPE + + - name: ASM Tests + working-directory: ${{runner.workspace}}/build + shell: bash + # Execute the unit tests + run: cmake --build . --config $BUILD_TYPE --target asm_tests + + - name: ASM Test Results move + if: ${{ always() }} + shell: bash + working-directory: ${{runner.workspace}}/build + run: mv ${{runner.workspace}}/build/Testing/Temporary/LastTest.log ${{runner.workspace}}/build/Testing/Temporary/LastTest_ASM.log || true + + - name: Truncate test results + if: ${{ always() }} + shell: bash + working-directory: ${{runner.workspace}}/build + # Cap out the log files at 20M in case something crash spins and dumps fault text + # ASM tests get quite close to 10MB + run: truncate --size=<20M ${{runner.workspace}}/build/Testing/Temporary/LastTest_*.log || true + + - name: Set runner name + if: ${{ always() }} + run: echo "runner_name=$(hostname)" >> $GITHUB_ENV + + - name: Upload results + if: ${{ always() }} + uses: 'actions/upload-artifact@v3' + timeout-minutes: 1 + with: + name: Results-${{ env.runner_name }} + path: ${{runner.workspace}}/build/Testing/Temporary/LastTest_*.log + retention-days: 3 + diff --git a/CMakeLists.txt b/CMakeLists.txt index a72584abe..58196db55 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,7 +113,6 @@ endif() if (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") set(_M_X86_64 1) - set(ENABLE_VIXL_SIMULATOR TRUE) add_definitions(-D_M_X86_64=1) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcx16") endif() diff --git a/FEXCore/CMakeLists.txt b/FEXCore/CMakeLists.txt index 23e35146d..0b453bcc8 100644 --- a/FEXCore/CMakeLists.txt +++ b/FEXCore/CMakeLists.txt @@ -6,7 +6,6 @@ project(${PROJECT_NAME} if (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") set(_M_X86_64 1) - set(ENABLE_VIXL_SIMULATOR TRUE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcx16") endif() diff --git a/FEXCore/Source/Interface/Core/HostFeatures.cpp b/FEXCore/Source/Interface/Core/HostFeatures.cpp index 023ee4274..3a0922716 100644 --- a/FEXCore/Source/Interface/Core/HostFeatures.cpp +++ b/FEXCore/Source/Interface/Core/HostFeatures.cpp @@ -7,6 +7,25 @@ #include "aarch64/disasm-aarch64.h" #include "aarch64/assembler-aarch64.h" +#ifdef _M_X86_64 +#define XBYAK64 +#define XBYAK_CUSTOM_ALLOC +#define XBYAK_CUSTOM_MALLOC FEXCore::Allocator::malloc +#define XBYAK_CUSTOM_FREE FEXCore::Allocator::free +#define XBYAK_CUSTOM_SETS +#define XBYAK_STD_UNORDERED_SET fextl::unordered_set +#define XBYAK_STD_UNORDERED_MAP fextl::unordered_map +#define XBYAK_STD_UNORDERED_MULTIMAP fextl::unordered_multimap +#define XBYAK_STD_LIST fextl::list +#define XBYAK_NO_EXCEPTION +#include +#include +#include + +#include +#include +#endif + namespace FEXCore { // Data Zero Prohibited flag @@ -35,7 +54,11 @@ static void SetFPCR(uint64_t Value) { __asm ("msr FPCR, %[Value]" :: [Value] "r" (Value)); } - +#else +static uint32_t GetDCZID() { + // Return unsupported + return DCZID_DZP_MASK; +} #endif static void OverrideFeatures(HostFeatures *Features) { @@ -267,6 +290,37 @@ HostFeatures::HostFeatures() { SupportsCLZERO = DCZID_Bytes == CPUIDEmu::CACHELINE_SIZE; } #endif + +#if defined(_M_X86_64) && !defined(VIXL_SIMULATOR) + Xbyak::util::Cpu X86Features{}; + SupportsAES = X86Features.has(Xbyak::util::Cpu::tAESNI); + SupportsCRC = X86Features.has(Xbyak::util::Cpu::tSSE42); + SupportsRAND = X86Features.has(Xbyak::util::Cpu::tRDRAND) && X86Features.has(Xbyak::util::Cpu::tRDSEED); + SupportsRCPC = true; + SupportsTSOImm9 = true; + Supports3DNow = X86Features.has(Xbyak::util::Cpu::t3DN) && X86Features.has(Xbyak::util::Cpu::tE3DN); + SupportsSSE4A = X86Features.has(Xbyak::util::Cpu::tSSE4a); + SupportsAVX = true; + SupportsSHA = X86Features.has(Xbyak::util::Cpu::tSHA); + SupportsBMI1 = X86Features.has(Xbyak::util::Cpu::tBMI1); + SupportsBMI2 = X86Features.has(Xbyak::util::Cpu::tBMI2); + SupportsCLWB = X86Features.has(Xbyak::util::Cpu::tCLWB); + SupportsPMULL_128Bit = X86Features.has(Xbyak::util::Cpu::tPCLMULQDQ); + + // xbyak doesn't know how to check for CLZero + // First ensure we support a new enough extended CPUID function range + + uint32_t data[4]; + Xbyak::util::Cpu::getCpuid(0x8000'0000, data); + if (data[0] >= 0x8000'0008U) { + // CLZero defined in 8000_00008_EBX[bit 0] + Xbyak::util::Cpu::getCpuid(0x8000'0008, data); + SupportsCLZERO = data[1] & 1; + } + + SupportsFlushInputsToZero = true; + SupportsFloatExceptions = true; +#endif OverrideFeatures(this); } } diff --git a/unittests/32Bit_ASM/CMakeLists.txt b/unittests/32Bit_ASM/CMakeLists.txt index 0e2d53460..5070afed9 100644 --- a/unittests/32Bit_ASM/CMakeLists.txt +++ b/unittests/32Bit_ASM/CMakeLists.txt @@ -48,14 +48,18 @@ foreach(ASM_SRC ${ASM_SOURCES}) list(APPEND ASM_DEPENDS "${OUTPUT_NAME};${OUTPUT_CONFIG_NAME}") - # Format is "" "" - set(TEST_ARGS - "--no-silent -g -c irjit -n 1 --no-multiblock" "jit_1" "jit" - "--no-silent -g -c irjit -n 500 --no-multiblock" "jit_500" "jit" - "--no-silent -g -c irjit -n 500 --multiblock" "jit_500_m" "jit" - ) + set(TEST_ARGS) + if (_M_ARM_64 OR ENABLE_VIXL_SIMULATOR) + list(APPEND TEST_ARGS + "--no-silent -g -c irjit -n 1 --no-multiblock" "jit_1" "jit" + "--no-silent -g -c irjit -n 500 --no-multiblock" "jit_500" "jit" + "--no-silent -g -c irjit -n 500 --multiblock" "jit_500_m" "jit" + ) + endif() - if (_M_X86_64) + if (ENABLE_VIXL_SIMULATOR) + set(CPU_CLASS Simulator) + elseif (_M_X86_64) list(APPEND TEST_ARGS "--no-silent -g -c host" "host" "host" ) diff --git a/unittests/ASM/CMakeLists.txt b/unittests/ASM/CMakeLists.txt index 2be2dfc64..36de82246 100644 --- a/unittests/ASM/CMakeLists.txt +++ b/unittests/ASM/CMakeLists.txt @@ -49,20 +49,22 @@ foreach(ASM_SRC ${ASM_SOURCES}) list(APPEND ASM_DEPENDS "${OUTPUT_NAME};${OUTPUT_CONFIG_NAME}") # Format is "" "" "" - set(TEST_ARGS - "--no-silent -g -c irjit -n 1 --no-multiblock" "jit_1" "jit" - "--no-silent -g -c irjit -n 500 --no-multiblock" "jit_500" "jit" - "--no-silent -g -c irjit -n 500 --multiblock" "jit_500_m" "jit" - ) + + set(TEST_ARGS) + if (_M_ARM_64 OR ENABLE_VIXL_SIMULATOR) + list(APPEND TEST_ARGS + "--no-silent -g -c irjit -n 1 --no-multiblock" "jit_1" "jit" + "--no-silent -g -c irjit -n 500 --no-multiblock" "jit_500" "jit" + "--no-silent -g -c irjit -n 500 --multiblock" "jit_500_m" "jit" + ) + endif() if (ENABLE_VIXL_SIMULATOR) set(CPU_CLASS Simulator) - else() - if (_M_X86_64) - list(APPEND TEST_ARGS - "--no-silent -g -c host" "host" "host" - ) - endif() + elseif (_M_X86_64) + list(APPEND TEST_ARGS + "--no-silent -g -c host" "host" "host" + ) endif() if (NOT MINGW_BUILD)