From a5e9828cc01c05352e7895c5b6f2670edf4b83ae Mon Sep 17 00:00:00 2001 From: Gerard Gorman Date: Fri, 19 Jul 2024 11:09:01 +0100 Subject: [PATCH] Reinstate AWS runner. --- .github/workflows/pytest-aws.yaml | 107 ++++++++++++++++++++++++++++++ devito/arch/compiler.py | 16 ++--- 2 files changed, 112 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/pytest-aws.yaml diff --git a/.github/workflows/pytest-aws.yaml b/.github/workflows/pytest-aws.yaml new file mode 100644 index 00000000000..4a193ec9565 --- /dev/null +++ b/.github/workflows/pytest-aws.yaml @@ -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 }} \ No newline at end of file diff --git a/devito/arch/compiler.py b/devito/arch/compiler.py index dbd361ae4ec..151bba868a0 100644 --- a/devito/arch/compiler.py +++ b/devito/arch/compiler.py @@ -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 @@ -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): @@ -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 = {