Skip to content

Commit

Permalink
i#6777: AArch64-ci: Add runner for 128 bit sve
Browse files Browse the repository at this point in the history
This patch configures the github CI to spawn 3 AArch64 precommit jobs
without sve, with sve 256 and with sve 128. This is accomplished by
a small python program which makes a call to set the vector length
and an update to the job matrix to spawn the appropriate jobs.

Change-Id: I238d883cd805e0a643e392fe481a0abf9359a058
  • Loading branch information
joshua-warburton committed May 9, 2024
1 parent 6fb84c6 commit 7a48c25
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 1 deletion.
19 changes: 18 additions & 1 deletion .github/workflows/ci-aarchxx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,17 @@ jobs:
fail-fast: false
matrix:
# This job will run in parallel.
os: [ubuntu-20-arm64, ubuntu-20-arm64-sve]
include:
- os: ubuntu-20-arm64
sve: false
- os: ubuntu-20-arm64-sve
sve: true
sve_length: 256
- os: ubuntu-20-arm64-sve
sve: true
sve_length: 128
runs-on: ${{ matrix.os }}
name: AArch64 ${{matrix.sve && 'SVE' || ''}} precommit ${{matrix.sve_length}}
steps:
- name: Check out repository code
uses: actions/checkout@v3
Expand Down Expand Up @@ -81,6 +90,14 @@ jobs:
run: ../suite/runsuite_wrapper.pl travis
env:
CI_BRANCH: ${{ github.ref }}
if: ${{ matrix.sve == false || matrix.sve_length == '' }}

- name: Run Suite with sve vector length ${{ matrix.sve_length }}
working-directory: build
run: ../tools/run_with_vector_length.py ${{ matrix.sve_length }} ../suite/runsuite_wrapper.pl travis
env:
CI_BRANCH: ${{ github.ref }}
if: ${{ matrix.sve == true && matrix.sve_length != ''}}

- name: Send failure mail to dynamorio-devs
if: failure() && github.ref == 'refs/heads/master'
Expand Down
34 changes: 34 additions & 0 deletions tools/get_vector_length.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env python3

"""
Print the vector length in the current context
"""

import ctypes
import sys

# These constants must match linux/prctl.h
PR_SVE_GET_VL = 51
PR_SVE_VL_LEN_MASK = 0xffff

def get_vector_length():
"""
Use Prctl(2) to set the process tree's sve vector length. See
https://man7.org/linux/man-pages/man2/prctl.2.html for more details
"""
libc = ctypes.cdll.LoadLibrary('libc.so.6')
return_code = libc.prctl(
PR_SVE_GET_VL)
if return_code < 0:
print(f'Failed to get VL, rc: {return_code}')
sys.exit(1)
print((return_code & PR_SVE_VL_LEN_MASK) * 8)

if __name__ == '__main__':
if any(arg in ["--help", "-h"] for arg in sys.argv) or len(sys.argv) > 1:
print(f"usage: {sys.argv[0]}")
print("\nGets the current vector length of this process tree")
sys.exit(0)

get_vector_length()

50 changes: 50 additions & 0 deletions tools/run_with_vector_length.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env python3

"""
Run a program as a subprocess after configuring the vector length of the
system to match the value in the first argument.
"""

import ctypes
import subprocess
import sys

# These constants must match linux/prctl.h
PR_SVE_SET_VL = 50

PR_SVE_VL_INHERIT = 1 << 17
PR_SVE_SET_VL_ONEXEC = 1 << 18
PR_SVE_VL_LEN_MASK = 0xffff

def set_vector_length(vector_length):
"""
Use Prctl(2) to set the process tree's sve vector length. See
https://man7.org/linux/man-pages/man2/prctl.2.html for more details
"""
vector_length_bytes = vector_length // 8
libc = ctypes.cdll.LoadLibrary('libc.so.6')
return_code = libc.prctl(
PR_SVE_SET_VL,
PR_SVE_SET_VL_ONEXEC | PR_SVE_VL_INHERIT | vector_length_bytes)
if return_code < 0:
print(f'Failed to set VL, rc: {return_code}')
sys.exit(1)
set_vector_length = (return_code & PR_SVE_VL_LEN_MASK) * 8

if set_vector_length != vector_length:
print(
f"Requested vector length {vector_length} not set, maximum of {set_vector_length} available",
file=sys.stderr)
sys.exit(1)

if __name__ == '__main__':
if any(arg in ["--help", "-h"] for arg in sys.argv) or len(sys.argv) < 3:
print(f"usage: {sys.argv[0]} [vector_length] [program] [program args]...")
print("\nSet the vector length of this process tree to [vector_length] bits")
print("and then execute [program]")
sys.exit(0)

set_vector_length(int(sys.argv[1]))

command = sys.argv[2:]
sys.exit(subprocess.run(command, check=False).returncode)
43 changes: 43 additions & 0 deletions tools/set_vector_length.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env python3

"""
Run a program as a subprocess after configuring the vector length of the
system to match the value in the first argument.
"""

import ctypes
import subprocess
import sys

# These constants must match linux/prctl.h
PR_SVE_SET_VL = 50
PR_SVE_GET_VL = 51

PR_SVE_VL_INHERIT = 1 << 17
PR_SVE_SET_VL_ONEXEC = 1 << 18
PR_SVE_VL_LEN_MASK = 0xffff

def set_vector_length(vector_length):
"""
Use Prctl(2) to set the process tree's sve vector length. See
https://man7.org/linux/man-pages/man2/prctl.2.html for more details
"""
libc = ctypes.cdll.LoadLibrary('libc.so.6')
return_code = libc.prctl(
PR_SVE_SET_VL,
PR_SVE_SET_VL_ONEXEC | PR_SVE_VL_INHERIT | vector_length)
if return_code < 0:
print(f'Failed to set VL, rc: {return_code}')
sys.exit(1)

if __name__ == '__main__':
if any(arg in ["--help", "-h"] for arg in sys.argv) or len(sys.argv) < 3:
print(f"usage: {sys.argv[0]} [vector_length] [program] [program args]...")
print("\nSet the vector length of this process tree to [vector_length]")
print("and then execute [program]")
sys.exit(0)

set_vector_length(int(sys.argv[1]))

command = sys.argv[2:]
subprocess.run(command, check=False)

0 comments on commit 7a48c25

Please sign in to comment.