diff --git a/.gitignore b/.gitignore index 5410ab3057195497518dbec83641d78c9988279b..5ec93d6ef6776bfa9199408192cd3403c15c6191 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .idea/ +.tox/ build/ venv/ pystencils_benchmark.egg-info/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..8a81d770d570f138277c2b5acbb09fcccee7047c --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,32 @@ +stages: + - docker-build + - test + +# ---------------------- Docker-build --------------------- +build-docker: + stage: docker-build + image: docker:latest + script: + - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY + - docker build --pull . -f Dockerfile -t i10git.cs.fau.de:5005/hoenig/pystencils-benchmark/pystencils-benchmark + - docker push i10git.cs.fau.de:5005/hoenig/pystencils-benchmark/pystencils-benchmark + tags: + - docker-docker + rules: + - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH + changes: + - Dockerfile + - when: manual + allow_failure: true + + +# ---------------------- Tests --------------------- +test: + stage: test + image: i10git.cs.fau.de:5005/hoenig/pystencils-benchmark/pystencils-benchmark + tags: + - docker + script: + - pip install tox + - echo $TOX_ENV + - tox diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..1e1847e71cec4d233b289219bb446744aa7e5f40 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM ubuntu:latest + +LABEL maintainer="jan.hoenig@fau.de" +LABEL version="0.1" +LABEL description="Custom docker image for pystencils-benchmark" + +ARG DEBIAN_FRONTEND=noninteractive + +RUN apt-get update + +RUN apt-get install -y \ + python3 \ + build-essential \ + clang \ + gcc && \ + rm -rf /var/lib/apt/lists/* && \ + apt-get clean + diff --git a/test.py b/examle/test.py similarity index 100% rename from test.py rename to examle/test.py diff --git a/requirements.txt b/requirements.txt index 14f8297af3fbe1ac3a55309850d333cb6604489a..16a3353dc7041dc6250743ba6583810e38556fc5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ Jinja2>=3.0.2 pystencils>=0.4.1 setuptools>=44.0.0 -numpy>=1.21.4 \ No newline at end of file +numpy>=1.21.4 +sympy>=1.9 \ No newline at end of file diff --git a/tests/test_benchmark.py b/tests/test_benchmark.py new file mode 100755 index 0000000000000000000000000000000000000000..b84aef3138009f5e09d0c245286a4843269cf94c --- /dev/null +++ b/tests/test_benchmark.py @@ -0,0 +1,26 @@ +import subprocess +import numpy as np +import sympy as sp +import pystencils as ps +from pystencils_benchmark import generate_benchmark, Compiler +from pathlib import Path + + +def test_generate(path: Path): + a, b, c = ps.fields(a=np.ones(4000000), b=np.ones(4000000), c=np.ones(4000000)) + alpha = sp.symbols('alpha') + + @ps.kernel_config(ps.CreateKernelConfig()) + def vadd(): + a[0] @= b[0] + c[0] + kernel_vadd = ps.create_kernel(**vadd) + + @ps.kernel_config(ps.CreateKernelConfig()) + def daxpy(): + b[0] @= alpha * a[0] + b[0] + kernel_daxpy = ps.create_kernel(**daxpy) + + for compiler in [Compiler.GCC, Compiler.GCCdebug, Compiler.Clang]: + generate_benchmark([kernel_vadd, kernel_daxpy], path, compiler=compiler) + subprocess.run(['make']) + subprocess.run([f'./benchmark-{compiler.name}', '100']) diff --git a/todo_gitlab-ci.yml b/todo_gitlab-ci.yml deleted file mode 100644 index a30b10c96cf2f38617e2cd55b8c4c644a683c59b..0000000000000000000000000000000000000000 --- a/todo_gitlab-ci.yml +++ /dev/null @@ -1,113 +0,0 @@ -stages: - - test - - build - - example-build - - example-test - - -# ---------------------- Tests --------------------- -.test_template: &test_definition - stage: test - tags: - - docker - script: - - pip install tox - - echo $TOX_ENV - - tox -e $TOX_ENV - artifacts: - when: always - reports: - junit: - - report.xml - -test-3.10: - image: python:3.10 - variables: - TOX_ENV: py310 - <<: *test_definition - -test-3.9: - image: python:3.9 - variables: - TOX_ENV: py39 - <<: *test_definition - -test-3.8: - image: python:3.8 - variables: - TOX_ENV: py38 - <<: *test_definition - -test-docs: - image: python:3.10 - tags: - - docker - script: - - pip install tox - - tox -e docs - - -# ------------------ Create documentation, image, pypy from studon-scripts ----------------- -pages: - stage: build - image: python:3.10 - script: - - pip install tox - - tox -e docs - - mv html_doc public - - artifacts: - paths: - - public - tags: - - docker - only: - - master - -build-docker: - stage: build - image: docker:latest - script: - - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY - - docker build --pull . -f Dockerfile -t i10git.cs.fau.de:5005/teaching/studon-scripts/studon-scripts - - docker push i10git.cs.fau.de:5005/teaching/studon-scripts/studon-scripts - tags: - - docker-docker - when: manual - -build-pypi: - stage: build - image: python:3.10 - script: - - pip install twine - - python3 setup.py sdist bdist_wheel - - TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python -m twine upload --verbose --repository-url https://i10git.cs.fau.de/api/v4/projects/${CI_PROJECT_ID}/packages/pypi dist/* - tags: - - docker - only: - refs: - - master - changes: - - setup.cfg - -# ------------------- Create an image for the example problem --------------- -example-build: - stage: example-build - image: docker:latest - script: - - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY - - docker build --build-arg READ_API=$READ_API --pull . -f ./test_resources/example/Dockerfile -t i10git.cs.fau.de:5005/teaching/studon-scripts/example - - docker push i10git.cs.fau.de:5005/teaching/studon-scripts/example - tags: - - docker-docker - when: manual - -# ------------------ Test created image on an example problem --------------- -example-test: - stage: example-test - image: i10git.cs.fau.de:5005/teaching/studon-scripts/example - script: - - cd test_resources/example - - bash example.sh - tags: - - docker diff --git a/tox.ini b/tox.ini index 294342c16aeff4873dee8c191788c19487356e31..28c7cf28e41f376bb09a7e6fa40022448506c5d0 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py38, py39, py310 +envlist = py39 requires = setuptools >= 40.0.0 [testenv]