Skip to content

Commit

Permalink
Reinstate AWS runner.
Browse files Browse the repository at this point in the history
  • Loading branch information
ggorman authored and mloubout committed Jul 20, 2024
1 parent a0c1a66 commit a5e9828
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 11 deletions.
107 changes: 107 additions & 0 deletions .github/workflows/pytest-aws.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: aws-ci

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
# Trigger the workflow on push or pull request,
# but only for the master branch
push:
branches:
- master
pull_request:
branches:
- master

jobs:

start-runner:
name: Start self-hosted EC2 runner
runs-on: ubuntu-latest

outputs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}

steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: "us-east-1"

- name: Start EC2 runner
id: start-ec2-runner
uses: machulav/ec2-github-runner@v2
with:
mode: start
github-token: ${{ secrets.AWS_CI_PAT }}
ec2-image-id: ami-0f2acee8eccac59fd
ec2-instance-type: c6g.4xlarge
subnet-id: subnet-0b4c118eb6ae48d63
security-group-id: sg-0b51f45ce1c1ad78f
aws-resource-tags: > # optional, requires additional permissions
[
{"Key": "Name", "Value": "ec2-github-runner"},
{"Key": "GitHubRepository", "Value": "${{ github.repository }}"}
]
do-the-job:
name: Do the job on the runner
needs: start-runner # required to start the main job when the runner is ready
runs-on: ${{ needs.start-runner.outputs.label }} # run the job on the newly created runner

env:
DEVITO_ARCH: "arm"
DEVITO_PLATFORM: "graviton"
DEVITO_LANGUAGE: "openmp"
OMP_NUM_THREADS: 2

steps:
- name: Checkout devito
uses: actions/checkout@v3

- name: Check arch
run: lscpu

- name: Install dependencies
if: "!contains(matrix.name, 'docker')"
run: |
pip3 install --upgrade pip
pip3 install -U -e .[tests]
pip3 install pytest-xdist
- name: Test with pytest
run: pytest -n 8 -k "not adjoint" -m "not parallel" --cov --cov-config=.coveragerc --cov-report=xml tests/

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
name: ${{ matrix.name }}

stop-runner:
name: Stop self-hosted EC2 runner
needs:
- start-runner # required to get output from the start-runner job
- do-the-job # required to wait when the main job is done
runs-on: ubuntu-latest
if: ${{ always() }} # required to stop the runner even if the error happened in the previous jobs

steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: Stop EC2 runner
uses: machulav/ec2-github-runner@v2
with:
mode: stop
github-token: ${{ secrets.AWS_CI_PAT }}
label: ${{ needs.start-runner.outputs.label }}
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }}
16 changes: 5 additions & 11 deletions devito/arch/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,8 @@ def __init_finalize__(self, **kwargs):
if platform in [POWER8, POWER9]:
# -march isn't supported on power architectures, is -mtune needed?
self.cflags = ['-mcpu=native'] + self.cflags
elif platform is Graviton:
# Graviton flag
mx = platform.march
self.cflags = ['-mcpu=%s' % mx] + self.cflags
elif isinstance(platform, Graviton):
self.cflags = ['-mcpu=%s' % platform.march] + self.cflags
else:
self.cflags = ['-march=native'] + self.cflags

Expand Down Expand Up @@ -466,9 +464,8 @@ def __init_finalize__(self, **kwargs):
platform = kwargs.pop('platform', configuration['platform'])

# Graviton flag
if platform is Graviton:
mx = platform.march
self.cflags += ['-mcpu=%s' % mx]
if isinstance(platform, Graviton):
self.cflags += ['-mcpu=%s' % platform.march]


class ClangCompiler(Compiler):
Expand Down Expand Up @@ -979,11 +976,8 @@ def __getitem__(self, key):
return partial(GNUCompiler, suffix=i)
return super().__getitem__(key)

def has_key(self, k):
return k in self.keys() or k.startswith('gcc-')

def __contains__(self, k):
return self.has_key(k)
return k in self.keys() or k.startswith('gcc-')


_compiler_registry = {
Expand Down

0 comments on commit a5e9828

Please sign in to comment.