Skip to content

Commit 61406c5

Browse files
committed
init big endian ci
1 parent 573eb76 commit 61406c5

File tree

1 file changed

+207
-0
lines changed

1 file changed

+207
-0
lines changed

.github/workflows/big_endian.yml

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
name: Test Big-Endian Systems
2+
3+
on:
4+
push:
5+
branches:
6+
- big-endian-ci
7+
pull_request:
8+
workflow_dispatch:
9+
10+
jobs:
11+
test-big-endian:
12+
name: Test Big-Endian Systems
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 120 # Big-endian emulation is slower
15+
strategy:
16+
fail-fast: false # Continue testing other architectures if one fails
17+
matrix:
18+
include:
19+
- arch: s390x
20+
platform: linux/s390x
21+
name: "IBM Z (s390x)"
22+
continue-on-error: true # Allow failures initially
23+
- arch: ppc64
24+
platform: linux/ppc64
25+
name: "PowerPC 64-bit"
26+
continue-on-error: true # Allow failures initially
27+
28+
continue-on-error: ${{ matrix.continue-on-error }}
29+
30+
steps:
31+
- uses: actions/checkout@v3
32+
with:
33+
submodules: recursive
34+
35+
- name: Set up QEMU
36+
uses: docker/setup-qemu-action@v3
37+
with:
38+
platforms: ${{ matrix.platform }}
39+
40+
- name: Set up Docker Buildx
41+
uses: docker/setup-buildx-action@v3
42+
43+
- name: Create test script
44+
run: |
45+
cat > test_script.sh << 'EOF'
46+
#!/bin/bash
47+
set -ex
48+
49+
echo "=== Starting Big-Endian Test for ${{ matrix.name }} ==="
50+
51+
# Update package list and install dependencies
52+
echo "=== Installing System Dependencies ==="
53+
apt-get update
54+
apt-get install -y python3 python3-pip python3-dev python3-venv
55+
apt-get install -y gcc g++ cmake make git pkg-config
56+
apt-get install -y libmpfr-dev libssl-dev libfftw3-dev
57+
58+
# Create and activate virtual environment
59+
echo "=== Setting up Python Environment ==="
60+
python3 -m venv /tmp/venv
61+
source /tmp/venv/bin/activate
62+
63+
# Install Python dependencies
64+
pip install -U pip build pytest unyt wheel meson ninja meson-python patchelf pandas numpy
65+
66+
# Verify we're on big-endian system
67+
echo "=== Endianness Check ==="
68+
python3 -c "
69+
import sys
70+
import struct
71+
print(f'Byte order: {sys.byteorder}')
72+
is_little = struct.pack('@I', 1) == struct.pack('<I', 1)
73+
print(f'Little endian: {is_little}')
74+
if is_little:
75+
print('ERROR: Expected big-endian system!')
76+
exit(1)
77+
else:
78+
print('SUCCESS: Confirmed big-endian system')
79+
"
80+
81+
# Install SLEEF
82+
echo "=== Building SLEEF ==="
83+
git clone --branch 3.8 https://github.com/shibatch/sleef.git
84+
cd sleef
85+
cmake -S . -B build \
86+
-DSLEEF_BUILD_QUAD:BOOL=ON \
87+
-DSLEEF_BUILD_SHARED_LIBS:BOOL=ON \
88+
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
89+
-DCMAKE_BUILD_TYPE=Release
90+
cmake --build build/ --clean-first -j$(nproc)
91+
cmake --install build --prefix /usr/local
92+
cd /workspace
93+
94+
# Verify SLEEF installation
95+
echo "=== Verifying SLEEF Installation ==="
96+
ls -la /usr/local/lib*/libsleef*
97+
ls -la /usr/local/include/sleef*
98+
99+
# Install and test quaddtype
100+
echo "=== Building and Testing QuadDType ==="
101+
cd quaddtype
102+
103+
# Verify submodules are present
104+
echo "=== Checking Submodules ==="
105+
ls -la numpy_quaddtype/QBLAS/
106+
ls -la numpy_quaddtype/QBLAS/include/quadblas/ || true
107+
108+
# Set up environment
109+
export CFLAGS="-I/usr/local/include -I$(pwd)/numpy_quaddtype/QBLAS/include"
110+
export CXXFLAGS="-I/usr/local/include -I$(pwd)/numpy_quaddtype/QBLAS/include -fext-numeric-literals"
111+
export LDFLAGS="-L/usr/local/lib64 -L/usr/local/lib -Wl,-rpath,/usr/local/lib64 -Wl,-rpath,/usr/local/lib -fopenmp"
112+
export LD_LIBRARY_PATH="/usr/local/lib64:/usr/local/lib:$LD_LIBRARY_PATH"
113+
114+
echo "Build environment:"
115+
echo "CFLAGS=$CFLAGS"
116+
echo "CXXFLAGS=$CXXFLAGS"
117+
echo "LDFLAGS=$LDFLAGS"
118+
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
119+
120+
# Install
121+
echo "=== Installing QuadDType ==="
122+
python -m pip install . -v --no-build-isolation \
123+
-Cbuilddir=build \
124+
-C'compile-args=-v' \
125+
-Csetup-args="-Dbuildtype=debug" \
126+
-Csetup-args="-Dcpp_args=-fext-numeric-literals" || {
127+
echo "=== Installation failed, showing build logs ==="
128+
find . -name "*.log" -exec cat {} \; || true
129+
exit 1
130+
}
131+
132+
# Test basic functionality
133+
echo "=== Basic QuadDType Test ==="
134+
python3 -c "
135+
import sys
136+
print(f'Python version: {sys.version}')
137+
print(f'Python executable: {sys.executable}')
138+
139+
import numpy as np
140+
print(f'NumPy version: {np.__version__}')
141+
142+
try:
143+
from numpy_quaddtype import QuadPrecDType
144+
print('✓ Successfully imported QuadPrecDType')
145+
146+
# Test basic array creation
147+
arr = np.array([1.0, 2.0, 3.0], dtype=QuadPrecDType())
148+
print(f'✓ Created array: {arr}')
149+
print(f'✓ Array dtype: {arr.dtype}')
150+
151+
# Test basic operations
152+
result = arr + arr
153+
print(f'✓ Addition result: {result}')
154+
155+
# Test multiplication
156+
mult_result = arr * 2.0
157+
print(f'✓ Multiplication result: {mult_result}')
158+
159+
print('✓ SUCCESS: Basic QuadDType operations work on big-endian!')
160+
161+
except Exception as e:
162+
print(f'✗ ERROR in basic test: {e}')
163+
import traceback
164+
traceback.print_exc()
165+
exit(1)
166+
"
167+
168+
# Run full test suite (with timeout protection)
169+
echo "=== Running Full Test Suite ==="
170+
timeout 1800 pytest -xvs --tb=short || {
171+
echo "=== Test suite failed or timed out ==="
172+
echo "This might be expected on big-endian systems during initial development"
173+
echo "Check the test output above for specific failures"
174+
exit 1
175+
}
176+
177+
echo "=== All Tests Completed Successfully ==="
178+
EOF
179+
180+
chmod +x test_script.sh
181+
182+
- name: Test on ${{ matrix.name }}
183+
run: |
184+
docker run --rm --platform=${{ matrix.platform }} \
185+
-v ${{ github.workspace }}:/workspace \
186+
-w /workspace \
187+
ubuntu:22.04 \
188+
bash -c "
189+
echo 'Container started for ${{ matrix.name }}'
190+
echo 'Architecture info:'
191+
uname -a
192+
cat /proc/cpuinfo | head -20 || true
193+
echo 'Starting test script...'
194+
./test_script.sh
195+
"
196+
197+
- name: Report Results
198+
if: always()
199+
run: |
200+
echo "Big-endian testing completed for ${{ matrix.name }}"
201+
if [ "${{ job.status }}" = "success" ]; then
202+
echo "✅ Tests passed!"
203+
elif [ "${{ matrix.continue-on-error }}" = "true" ]; then
204+
echo "⚠️ Tests failed, but continuing (expected during development)"
205+
else
206+
echo "❌ Tests failed!"
207+
fi

0 commit comments

Comments
 (0)