Merge pull request #7 from OldCrow/v0.12.1-pre-distribution-refactori… #28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: AVX-512 Compilation Verification | |
permissions: | |
contents: read | |
# This workflow tests AVX-512 code compilation without linking or runtime testing | |
# Limitation: Cannot test full linking due to GitHub runners lacking AVX-512 hardware | |
# Benefit: Validates AVX-512 syntax, headers, and intrinsics across compilers | |
on: | |
push: | |
branches: [ main, develop, 'release/*', 'v*' ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
avx512-compile: | |
name: AVX-512 Compilation Test (Syntax Only) | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
compiler: | |
- { name: gcc-12, cc: gcc-12, cxx: g++-12 } | |
- { name: clang-15, cc: clang-15, cxx: clang++-15 } | |
build_type: [Debug, Release] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Compilers | |
run: | | |
sudo apt-get update | |
if [[ "${{ matrix.compiler.cc }}" == gcc* ]]; then | |
sudo apt-get install -y ${{ matrix.compiler.cc }} ${{ matrix.compiler.cxx }} | |
elif [[ "${{ matrix.compiler.cc }}" == clang* ]]; then | |
sudo apt-get install -y ${{ matrix.compiler.cc }} | |
# Install clang++-15 explicitly | |
sudo apt-get install -y clang++-15 | |
fi | |
- name: Set Compiler Environment | |
run: | | |
echo "CC=${{ matrix.compiler.cc }}" >> $GITHUB_ENV | |
echo "CXX=${{ matrix.compiler.cxx }}" >> $GITHUB_ENV | |
- name: Configure CMake for AVX-512 Compilation | |
run: | | |
cmake -B build \ | |
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ | |
-DCMAKE_CXX_STANDARD=20 \ | |
-DCMAKE_CXX_FLAGS="-mavx512f -mavx512dq -mavx512bw -mavx512vl -DLIBSTATS_HAS_AVX512" \ | |
-DLIBSTATS_ENABLE_AVX512=ON \ | |
-DLIBSTATS_FORCE_AVX512=ON \ | |
-DLIBSTATS_TEST_AVX512_COMPILATION=ON | |
- name: Compile AVX-512 Source Files | |
run: | | |
echo "=== Compiling AVX-512 source files individually ===" | |
# Test compilation of AVX-512 source with forced flags | |
echo "Testing simd_avx512.cpp compilation..." | |
${{ matrix.compiler.cxx }} \ | |
-I include -I . \ | |
-std=c++20 \ | |
-DLIBSTATS_HAS_AVX512 \ | |
-mavx512f -mavx512dq -mavx512bw -mavx512vl \ | |
-c src/simd_avx512.cpp \ | |
-o avx512_test.o || echo "AVX-512 source compilation failed" | |
# Test compilation of dispatch logic with AVX-512 enabled | |
echo "Testing simd_dispatch.cpp with AVX-512 enabled..." | |
${{ matrix.compiler.cxx }} \ | |
-I include -I . \ | |
-std=c++20 \ | |
-DLIBSTATS_HAS_AVX512 \ | |
-mavx512f -mavx512dq -mavx512bw -mavx512vl \ | |
-c src/simd_dispatch.cpp \ | |
-o dispatch_avx512_test.o || echo "Dispatch compilation failed" | |
echo "✅ Individual source file compilation tests completed" | |
echo "=== Checking for AVX-512 symbols in compiled code ===" | |
# Check if AVX-512 instructions are present in the compiled SIMD files | |
if [ -f "build/CMakeFiles/libstats_simd_obj.dir/src/simd_avx512.cpp.o" ]; then | |
echo "✅ simd_avx512.cpp compiled successfully" | |
objdump -d build/CMakeFiles/libstats_simd_obj.dir/src/simd_avx512.cpp.o | grep -i "avx512\\|zmm" || echo "No AVX-512 instructions found in object file" | |
else | |
echo "❌ simd_avx512.cpp object file not found" | |
fi | |
- name: Verify AVX-512 Code Compilation | |
run: | | |
echo "=== Verifying AVX-512 specific files compiled ===" | |
find build -name "*.o" -exec sh -c 'echo "=== $1 ==="; nm "$1" | grep -E "(avx512|zmm|_mm512)" | head -5 || echo "No AVX-512 symbols found"' _ {} \; | |
- name: Test AVX-512 Header Parsing | |
run: | | |
echo "=== Testing AVX-512 header parsing ===" | |
# Create a simple test to ensure AVX-512 headers parse correctly | |
cat > test_avx512_headers.cpp << 'EOF' | |
#include <immintrin.h> | |
#include <cstdio> | |
// Test that we can compile AVX-512 code | |
int main() { | |
// This will only compile if AVX-512 is properly supported | |
__m512d zero = _mm512_setzero_pd(); | |
__m512d ones = _mm512_set1_pd(1.0); | |
__m512d result = _mm512_add_pd(zero, ones); | |
printf("AVX-512 compilation test passed\\n"); | |
return 0; | |
} | |
EOF | |
echo "Compiling AVX-512 header test..." | |
${{ matrix.compiler.cxx }} -mavx512f -mavx512dq -c test_avx512_headers.cpp -o test_avx512_headers.o | |
echo "✅ AVX-512 headers compile successfully with ${{ matrix.compiler.name }}" | |
- name: Summary | |
run: | | |
echo "=== AVX-512 Compilation Summary ===" | |
echo "✅ AVX-512 code compiles with ${{ matrix.compiler.name }} in ${{ matrix.build_type }} mode" | |
echo "✅ AVX-512 headers are accessible and functional" | |
echo "✅ Project builds successfully with AVX-512 flags enabled" | |
echo "" | |
echo "Note: This tests compilation only. Runtime testing requires AVX-512 capable hardware." |