Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 66-absolute-access-is-probably-not-copied-correctly-after-_eval_subs
  • const_fix
  • fhennig/v2.0-deprecations
  • fma
  • gpu_bufferfield_fix
  • gpu_liveness_opts
  • holzer-master-patch-46757
  • hyteg
  • improved_comm
  • master
  • target_dh_refactoring
  • v2.0-dev
  • vectorization_sqrt_fix
  • zikeliml/124-rework-tutorials
  • zikeliml/Task-96-dotExporterForAST
  • last/Kerncraft
  • last/LLVM
  • last/OpenCL
  • release/0.2.1
  • release/0.2.10
  • release/0.2.11
  • release/0.2.12
  • release/0.2.13
  • release/0.2.14
  • release/0.2.15
  • release/0.2.2
  • release/0.2.3
  • release/0.2.4
  • release/0.2.6
  • release/0.2.7
  • release/0.2.8
  • release/0.2.9
  • release/0.3.0
  • release/0.3.1
  • release/0.3.2
  • release/0.3.3
  • release/0.3.4
  • release/0.4.0
  • release/0.4.1
  • release/0.4.2
  • release/0.4.3
  • release/0.4.4
  • release/1.0
  • release/1.0.1
  • release/1.1
  • release/1.1.1
  • release/1.2
  • release/1.3
  • release/1.3.1
  • release/1.3.2
  • release/1.3.3
  • release/1.3.4
  • release/1.3.5
  • release/1.3.6
  • release/1.3.7
  • release/2.0.dev0
56 results

Target

Select target project
No results found
Select Git revision
  • BenchMarkCUDA
  • FIX_Boundary_kwargs
  • Fix-doc
  • FixDoc
  • FixMod
  • GPU_alignment
  • Neon_Intrinsics
  • Revision3
  • SmallFixes
  • SmallPolish
  • Sympy_minimal
  • Testing
  • TypeSystem
  • UpSympy
  • Update_parallel_datahandling
  • UpgradeSympy
  • VecSparse
  • assembly
  • change-loop-variable-type
  • compare_fix
  • const_fix
  • dev
  • develop
  • gpu_liveness_opts
  • hyteg
  • improved_comm
  • int64
  • jan_test
  • master
  • struct
  • target_dh_refactoring
  • testConda
  • test_martin2
  • test_vectorisation
  • testing
  • version_number
  • warnings
  • last/Kerncraft
  • last/LLVM
  • last/OpenCL
  • release/0.2.1
  • release/0.2.10
  • release/0.2.11
  • release/0.2.12
  • release/0.2.13
  • release/0.2.14
  • release/0.2.15
  • release/0.2.2
  • release/0.2.3
  • release/0.2.4
  • release/0.2.6
  • release/0.2.7
  • release/0.2.8
  • release/0.2.9
  • release/0.3.0
  • release/0.3.1
  • release/0.3.2
  • release/0.3.3
  • release/0.3.4
  • release/0.4.0
  • release/0.4.1
  • release/0.4.2
  • release/0.4.3
  • release/0.4.4
  • release/1.0
  • release/1.0.1
  • release/1.1
  • release/1.1.1
  • release/1.2
  • release/1.3
  • release/1.3.1
  • release/1.3.2
  • release/1.3.3
  • release/1.3.4
  • release/1.3.5
  • release/1.3.6
  • release/2.0.dev0
77 results
Show changes

Commits on Source 282

182 additional commits have been omitted to prevent performance issues.
235 files
+ 12158
8987
Compare changes
  • Side-by-side
  • Inline

Files

+3 −3
Original line number Original line Diff line number Diff line
[flake8]
[flake8]
max-line-length=120
max-line-length=120
exclude=pystencils/jupyter.py,
exclude=src/pystencils/jupyter.py,
        pystencils/plot.py
        src/pystencils/plot.py
        pystencils/session.py
        src/pystencils/session.py
ignore = W293 W503 W291 C901 E741
ignore = W293 W503 W291 C901 E741
+1 −1
Original line number Original line Diff line number Diff line
pystencils/_version.py export-subst
src/pystencils/_version.py export-subst
+8 −7
Original line number Original line Diff line number Diff line
@@ -5,7 +5,7 @@ __pycache__
*.vti
*.vti
/build
/build
/dist
/dist
/*.egg-info
*.egg-info
.cache
.cache
_build
_build
/html_doc
/html_doc
@@ -15,15 +15,16 @@ _build
_local_tmp
_local_tmp
RELEASE-VERSION
RELEASE-VERSION
test-report
test-report
pystencils/boundaries/createindexlistcython.c
src/pystencils/boundaries/createindexlistcython.c
pystencils/boundaries/createindexlistcython.*.so
src/pystencils/boundaries/createindexlistcython.*.so
pystencils_tests/tmp
tests/tmp
pystencils_tests/var
tests/var
pystencils_tests/kerncraft_inputs/.2d-5pt.c_kerncraft/
tests/kerncraft_inputs/.2d-5pt.c_kerncraft/
pystencils_tests/kerncraft_inputs/.3d-7pt.c_kerncraft/
tests/kerncraft_inputs/.3d-7pt.c_kerncraft/
report.xml
report.xml
coverage_report/
coverage_report/




# macOS
# macOS
**/.DS_Store
**/.DS_Store
*.uuid
+137 −97
Original line number Original line Diff line number Diff line
stages:
stages:
  - pretest
  - pretest
  - test
  - test
  - nightly
  - docs
  - deploy
  - deploy




# --------------------------  Templates ------------------------------------------------------------------------------------

# Base configuration for jobs meant to run at every commit
.every-commit:
  rules:
    - if: $CI_PIPELINE_SOURCE != "schedule"

# Configuration for jobs meant to run on each commit to pycodegen/pystencils/master
.every-commit-master:
  rules:
    - if: '$CI_PIPELINE_SOURCE != "schedule" && $CI_PROJECT_PATH == "pycodegen/pystencils" && $CI_COMMIT_BRANCH == "master"'

# Base configuration for jobs meant to run at a schedule
.scheduled:
  rules:
    - if: $CI_PIPELINE_SOURCE == "schedule"

# --------------------------  Tests ------------------------------------------------------------------------------------
# --------------------------  Tests ------------------------------------------------------------------------------------


# Normal test - runs on every commit all but "long run" tests
# Normal test - runs on every commit all but "long run" tests
tests-and-coverage:
tests-and-coverage:
  stage: pretest
  stage: pretest
  except:
  extends: .every-commit
    variables:
  image: i10git.cs.fau.de:5005/pycodegen/pycodegen/full:cupy12.3
      - $ENABLE_NIGHTLY_BUILDS
  before_script:
  image: i10git.cs.fau.de:5005/pycodegen/pycodegen/full
    - pip install -e .
  script:
  script:
    - pip install sympy --upgrade
    - env
    - env
    - pip list
    - pip list
    - export NUM_CORES=$(nproc --all)
    - export NUM_CORES=$(nproc --all)
    - mkdir -p ~/.config/matplotlib
    - mkdir -p ~/.config/matplotlib
    - echo "backend:template" > ~/.config/matplotlib/matplotlibrc
    - echo "backend:template" > ~/.config/matplotlib/matplotlibrc
    - mkdir public
    - mkdir public
    - py.test -v -n $NUM_CORES --cov-report html --cov-report term --cov=. -m "not longrun" --html test-report/index.html --junitxml=report.xml
    - pytest -v -n $NUM_CORES --cov-report html --cov-report xml --cov-report term --cov=. -m "not longrun" --html test-report/index.html --junitxml=report.xml
    - python3 -m coverage xml
    - python -m coverage xml
  tags:
  tags:
    - docker
    - docker
    - cuda11
    - cuda11
    - AVX
    - AVX
  coverage: /Total coverage:\s\d+.\d+\%/
  artifacts:
  artifacts:
    when: always
    when: always
    paths:
    paths:
      - coverage_report
      - coverage_report
      - test-report
      - test-report
    reports:
    reports:
      cobertura: coverage.xml
      coverage_report:
        coverage_format: cobertura
        path: coverage.xml
      junit: report.xml
      junit: report.xml


# pipeline with latest python version
# Normal test with longruns
latest-python:
tests-and-coverage-with-longrun:
  stage: test
  stage: test
  except:
  when: manual
    variables:
  allow_failure: true
      - $ENABLE_NIGHTLY_BUILDS
  image: i10git.cs.fau.de:5005/pycodegen/pycodegen/full:cupy12.3
  image: i10git.cs.fau.de:5005/pycodegen/pycodegen/latest_python
  before_script:
    - pip install sympy --upgrade
    - pip install -e .
  script:
  script:
    - env
    - env
    - pip list
    - pip list
@@ -50,74 +73,66 @@ latest-python:
    - mkdir -p ~/.config/matplotlib
    - mkdir -p ~/.config/matplotlib
    - echo "backend:template" > ~/.config/matplotlib/matplotlibrc
    - echo "backend:template" > ~/.config/matplotlib/matplotlibrc
    - mkdir public
    - mkdir public
    - py.test -v -n $NUM_CORES -m "not longrun" --junitxml=report.xml
    - py.test -v -n $NUM_CORES
  tags:
  tags:
    - docker
    - docker
    - cuda11
    - AVX
    - AVX
  artifacts:
    when: always
    reports:
      junit: report.xml


# Nightly test  - runs "long run" jobs only
# pipeline with latest python version
test-longrun:
latest-python:
  stage: test
  stage: test
  only:
  extends: .every-commit
    variables:
  image: i10git.cs.fau.de:5005/pycodegen/pycodegen/latest_python
      - $ENABLE_NIGHTLY_BUILDS
  before_script:
  image: i10git.cs.fau.de:5005/pycodegen/pycodegen/full
    - pip install -e .
  script:
  script:
    - env
    - pip list
    - pip install -e .
    - export NUM_CORES=$(nproc --all)
    - export NUM_CORES=$(nproc --all)
    - mkdir -p ~/.config/matplotlib
    - mkdir -p ~/.config/matplotlib
    - echo "backend:template" > ~/.config/matplotlib/matplotlibrc
    - echo "backend:template" > ~/.config/matplotlib/matplotlibrc
    - py.test -v -n $NUM_CORES --cov-report html --cov-report term --cov=. --html test-report/index.html --junitxml=report.xml
    - mkdir public
    - py.test -v -n $NUM_CORES -m "not longrun" --junitxml=report.xml
  tags:
  tags:
    - docker
    - docker
    - cuda11
    - AVX
    - AVX
  artifacts:
  artifacts:
    when: always
    when: always
    paths:
      - coverage_report
      - test-report
    reports:
    reports:
      junit: report.xml
      junit: report.xml



# Minimal tests in windows environment
# Minimal tests in windows environment
minimal-windows:
#minimal-windows:
  stage: test
#  stage: test
  except:
#  tags:
    variables:
#    - win
      - $ENABLE_NIGHTLY_BUILDS
#  script:
  tags:
#    - export NUM_CORES=$(nproc --all)
    - win
#    - source /cygdrive/c/Users/build/Miniconda3/Scripts/activate
  script:
#    - source activate pystencils
    - export NUM_CORES=$(nproc --all)
#    - pip install joblib
    - source /cygdrive/c/Users/build/Miniconda3/Scripts/activate
#    - pip list
    - source activate pystencils
#    - python -c "import numpy"
    - pip install joblib
#    - py.test -v -m "not (notebook or longrun)"
    - pip list
    - python -c "import numpy"
    - py.test -v -m "not (notebook or longrun)"


ubuntu:
ubuntu:
  stage: test
  stage: test
  except:
  extends: .every-commit
    variables:
      - $ENABLE_NIGHTLY_BUILDS
  image: i10git.cs.fau.de:5005/pycodegen/pycodegen/ubuntu
  image: i10git.cs.fau.de:5005/pycodegen/pycodegen/ubuntu
  before_script:
  before_script:
    # - apt-get -y remove python3-sympy
    - ln -s /usr/include/locale.h /usr/include/xlocale.h
    - ln -s /usr/include/locale.h /usr/include/xlocale.h
    # - pip3 install `grep -Eo 'sympy[>=]+[0-9\.]+' setup.py | sed 's/>/=/g'`
    - pip3 install -e .
  script:
  script:
    - export NUM_CORES=$(nproc --all)
    - export NUM_CORES=$(nproc --all)
    - mkdir -p ~/.config/matplotlib
    - mkdir -p ~/.config/matplotlib
    - echo "backend:template" > ~/.config/matplotlib/matplotlibrc
    - echo "backend:template" > ~/.config/matplotlib/matplotlibrc
    - sed -i 's/--doctest-modules //g' pytest.ini
    - sed -i 's/--doctest-modules //g' pytest.ini
    - env
    - env
    - pip3 list
    - pip list
    - pytest-3 -v -n $NUM_CORES -m "not longrun" --junitxml=report.xml
    - pytest -v -n $NUM_CORES -m "not longrun" --junitxml=report.xml
  tags:
  tags:
    - docker
    - docker
    - cuda11
    - cuda11
@@ -129,10 +144,11 @@ ubuntu:


.multiarch_template:
.multiarch_template:
  stage: test
  stage: test
  except:
  extends: .every-commit
    variables:
  allow_failure: true
      - $ENABLE_NIGHTLY_BUILDS
  before_script: &multiarch_before_script
  before_script: &multiarch_before_script
    # - pip3 install -v .
    - export PYTHONPATH=src
    - python3 -c "import pystencils as ps; ps.cpu.cpujit.read_config()"
    - python3 -c "import pystencils as ps; ps.cpu.cpujit.read_config()"
    - sed -i '/^fail_under.*/d' pytest.ini
    - sed -i '/^fail_under.*/d' pytest.ini
  script:
  script:
@@ -142,72 +158,68 @@ ubuntu:
    - sed -i 's/--doctest-modules //g' pytest.ini
    - sed -i 's/--doctest-modules //g' pytest.ini
    - env
    - env
    - pip3 list
    - pip3 list
    - pytest-3 -v -n $NUM_CORES --junitxml=report.xml pystencils_tests/test_*vec*.py pystencils_tests/test_random.py
    - python3 -m pytest -v -n $NUM_CORES --reruns 2 --cov-report html --cov-report xml --cov=. --junitxml=report.xml tests/test_*vec*.py tests/test_random.py tests/test_half_precision.py
    - python3 -m coverage xml
  tags:
  tags:
    - docker
    - docker
    - AVX
    - multiarch
  artifacts:
  artifacts:
    when: always
    when: always
    paths:
      - coverage_report
    reports:
    reports:
      coverage_report:
        coverage_format: cobertura
        path: coverage.xml
      junit: report.xml
      junit: report.xml


arm64v8:
arm64v8:
  extends: .multiarch_template
  extends: .multiarch_template
  image: i10git.cs.fau.de:5005/pycodegen/pycodegen/arm64
  image: i10git.cs.fau.de:5005/pycodegen/pycodegen/arm64
  variables:
  variables:
    PYSTENCILS_SIMD: "neon"
    QEMU_CPU: "cortex-a76"
  before_script:
  before_script:
    - *multiarch_before_script
    - *multiarch_before_script
    - sed -i s/march=native/march=armv8-a/g ~/.config/pystencils/config.json


ppc64le:
ppc64le:
  extends: .multiarch_template
  extends: .multiarch_template
  image: i10git.cs.fau.de:5005/pycodegen/pycodegen/ppc64le
  image: i10git.cs.fau.de:5005/pycodegen/pycodegen/ppc64le
  variables:
    PYSTENCILS_SIMD: "vsx"
  before_script:
  before_script:
    - *multiarch_before_script
    - *multiarch_before_script
    - sed -i s/mcpu=native/mcpu=power8/g ~/.config/pystencils/config.json


arm64v9:
arm64v9:
  # Compiler support for SVE is still pretty rough: GCC 10+11 produce incorrect code for fixed-width vectors,
  # SVE support is still unreliable in GCC 13 (incorrect code for fixed-width vectors, internal compiler errors).
  # while Clang 12 produces memory-corrupting heisenbugs unless we enable the address sanitizer.
  # For half precision Clang is necessary
  # In the RNG tests, GCC 10+11 produce an internal compiler error.
  # The memory corruption seems to only happen with qemu-user, not with qemu-system.
  # Once the compilers and QEMU have improved, this job should be cleaned up to match the others.
  extends: .multiarch_template
  extends: .multiarch_template
  image: i10git.cs.fau.de:5005/pycodegen/pycodegen/arm64
  image: i10git.cs.fau.de:5005/pycodegen/pycodegen/arm64
  variables:
  variables:
    PYSTENCILS_SIMD: "sve256,sve512,sve"
    # disable pointer authentication to speed up emulation by 3x
    ASAN_OPTIONS: detect_leaks=0
    QEMU_CPU: "max,pauth-impdef=on"
    LD_PRELOAD: /usr/lib/aarch64-linux-gnu/libasan.so.6
  before_script:
  before_script:
    - *multiarch_before_script
    - *multiarch_before_script
    - sed -i s/march=native/march=armv8-a+sve/g ~/.config/pystencils/config.json
    - sed -i s/g\+\+/clang++/g ~/.config/pystencils/config.json
    - sed -i s/g\+\+/clang++/g ~/.config/pystencils/config.json


riscv64:
riscv64:
  # The RISC-V vector extension is still experimental and needs special compiler flags.
  # RISC-V vector extension support is incomplete in GCC 13.
  # Once they are officially released, this job should be cleaned up to match the others.
  extends: .multiarch_template
  extends: .multiarch_template
  image: i10git.cs.fau.de:5005/pycodegen/pycodegen/riscv64
  image: i10git.cs.fau.de:5005/pycodegen/pycodegen/riscv64
  variables:
  variables:
    # explicitly set SIMD as detection requires QEMU >= 8.1
    PYSTENCILS_SIMD: "rvv"
    PYSTENCILS_SIMD: "rvv"
    QEMU_CPU: "rv64,v=true"
    QEMU_CPU: "rv64,v=true,zicboz=true"
  before_script:
  before_script:
    - *multiarch_before_script
    - *multiarch_before_script
    - sed -i 's/march=native/march=rv64imfdv0p10 -menable-experimental-extensions/g' ~/.config/pystencils/config.json
    - sed -i 's/march=native/march=rv64imfdvzicboz/g' ~/.config/pystencils/config.json
    - sed -i s/g\+\+/clang++/g ~/.config/pystencils/config.json
    - sed -i s/g\+\+/clang++/g ~/.config/pystencils/config.json
    - sed -i 's/fopenmp/fopenmp=libgomp -I\/usr\/include\/riscv64-linux-gnu/g' ~/.config/pystencils/config.json


minimal-conda:
minimal-conda:
  stage: pretest
  stage: pretest
  except:
  extends: .every-commit
    variables:
      - $ENABLE_NIGHTLY_BUILDS
  image: i10git.cs.fau.de:5005/pycodegen/pycodegen/minimal_conda
  image: i10git.cs.fau.de:5005/pycodegen/pycodegen/minimal_conda
  before_script:
    - pip install -e .
  script:
  script:
    - python setup.py quicktest
    - python quicktest.py
  tags:
  tags:
    - docker
    - docker
    - cuda
    - cuda
@@ -215,13 +227,13 @@ minimal-conda:


minimal-sympy-master:
minimal-sympy-master:
  stage: test
  stage: test
  except:
  extends: .every-commit
    variables:
      - $ENABLE_NIGHTLY_BUILDS
  image: i10git.cs.fau.de:5005/pycodegen/pycodegen/minimal_conda
  image: i10git.cs.fau.de:5005/pycodegen/pycodegen/minimal_conda
  before_script:
    - pip install -e .
  script:
  script:
    - python -m pip install --upgrade git+https://github.com/sympy/sympy.git
    - python -m pip install --upgrade git+https://github.com/sympy/sympy.git
    - python setup.py quicktest
    - python quicktest.py
  allow_failure: true
  allow_failure: true
  tags:
  tags:
    - docker
    - docker
@@ -247,7 +259,6 @@ pycodegen-integration:
    - cd ..
    - cd ..
    - pip install -e pystencils/
    - pip install -e pystencils/
    - pip install -e lbmpy/
    - pip install -e lbmpy/
    - pip install -e pygrandchem/
    - cmake --version
    - cmake --version
    - ./install_walberla.sh
    - ./install_walberla.sh
    - export NUM_CORES=$(nproc --all)
    - export NUM_CORES=$(nproc --all)
@@ -257,14 +268,12 @@ pycodegen-integration:
    - py.test -v -n $NUM_CORES --junitxml=report.xml .
    - py.test -v -n $NUM_CORES --junitxml=report.xml .
    - cd ../lbmpy
    - cd ../lbmpy
    - py.test -v -n $NUM_CORES --junitxml=report.xml .
    - py.test -v -n $NUM_CORES --junitxml=report.xml .
    - cd ../pygrandchem
    - py.test -v -n $NUM_CORES --junitxml=report.xml .
    - cd ../walberla/build/
    - cd ../walberla/build/
    - make -j $NUM_CORES CodegenJacobiCPU CodegenJacobiGPU CodegenPoissonCPU CodegenPoissonGPU MicroBenchmarkGpuLbm LbCodeGenerationExample
    - make -j $NUM_CORES CodegenJacobiCPU CodegenJacobiGPU CodegenPoissonCPU CodegenPoissonGPU MicroBenchmarkGpuLbm LbCodeGenerationExample
    - make -j $NUM_CORES multiphaseCPU multiphaseGPU FluctuatingMRT FlowAroundSphereCodeGen
    - make -j $NUM_CORES multiphaseCPU multiphaseGPU FluctuatingMRT FlowAroundSphereCodeGen FieldLayoutAndVectorizationTest GeneratedOutflowBC
    - cd apps/benchmarks/UniformGridGPU
    - cd apps/benchmarks/UniformGridGPU
    - make -j $NUM_CORES
    - make -j $NUM_CORES
    - cd ../UniformGridGenerated
    - cd ../UniformGridCPU
    - make -j $NUM_CORES
    - make -j $NUM_CORES
  tags:
  tags:
    - docker
    - docker
@@ -275,26 +284,57 @@ pycodegen-integration:
    reports:
    reports:
      junit: pycodegen/*/report.xml
      junit: pycodegen/*/report.xml



# -------------------- Scheduled Tasks --------------------------------------------------------------------------


# Nightly test against the latest (pre-release) version of SymPy published on PyPI
nightly-sympy:
  stage: nightly
  needs: []
  extends: .scheduled
  image: i10git.cs.fau.de:5005/pycodegen/pycodegen/latest_python
  before_script:
    - pip install -e .
    - pip install --upgrade --pre sympy
  script:
    - env
    - pip list
    - export NUM_CORES=$(nproc --all)
    - mkdir -p ~/.config/matplotlib
    - echo "backend:template" > ~/.config/matplotlib/matplotlibrc
    - mkdir public
    - pytest -v -n $NUM_CORES -m "not longrun" --junitxml=report.xml
  tags:
    - docker
    - AVX
    - cuda
  artifacts:
    when: always
    reports:
      junit: report.xml

# -------------------- Linter & Documentation --------------------------------------------------------------------------
# -------------------- Linter & Documentation --------------------------------------------------------------------------




flake8-lint:
flake8-lint:
  stage: pretest
  stage: pretest
  except:
  extends: .every-commit
    variables:
      - $ENABLE_NIGHTLY_BUILDS
  image: i10git.cs.fau.de:5005/pycodegen/pycodegen/full
  image: i10git.cs.fau.de:5005/pycodegen/pycodegen/full
  script:
  script:
    - flake8 pystencils
    - flake8 src/pystencils
  tags:
  tags:
    - docker
    - docker




build-documentation:
build-documentation:
  stage: test
  stage: docs
  extends: .every-commit
  image: i10git.cs.fau.de:5005/pycodegen/pycodegen/documentation
  image: i10git.cs.fau.de:5005/pycodegen/pycodegen/documentation
  needs: []
  before_script:
    - pip install -e .
  script:
  script:
    - export PYTHONPATH=`pwd`
    - mkdir html_doc
    - mkdir html_doc
    - sphinx-build -b html doc  html_doc
    - sphinx-build -b html doc  html_doc
    - sphinx-build -W -b html doc  html_doc
    - sphinx-build -W -b html doc  html_doc
@@ -307,7 +347,9 @@ build-documentation:


pages:
pages:
  image: i10git.cs.fau.de:5005/pycodegen/pycodegen/full
  image: i10git.cs.fau.de:5005/pycodegen/pycodegen/full
  extends: .every-commit-master
  stage: deploy
  stage: deploy
  needs: ["tests-and-coverage", "build-documentation"]
  script:
  script:
    - ls -l
    - ls -l
    - mv coverage_report html_doc
    - mv coverage_report html_doc
@@ -317,5 +359,3 @@ pages:
      - public
      - public
  tags:
  tags:
    - docker
    - docker
  only:
    - master@pycodegen/pystencils
+1 −6
Original line number Original line Diff line number Diff line
include README.md
include COPYING.txt
include AUTHORS.txt
include AUTHORS.txt
include CONTRIBUTING.md
include CONTRIBUTING.md
CHANGELOG.md
include CHANGELOG.md
global-include *.pyx
include versioneer.py
include pystencils/_version.py
+6 −3
Original line number Original line Diff line number Diff line
@@ -52,7 +52,7 @@ pip install pystencils[interactive]
Without `[interactive]` you get a minimal version with very little dependencies.
Without `[interactive]` you get a minimal version with very little dependencies.


All options:
All options:
- `gpu`: use this if an NVIDIA GPU is available and CUDA is installed
- `gpu`: use this if an NVIDIA or AMD GPU is available and CUDA or ROCm is installed
- `alltrafos`: pulls in additional dependencies for loop simplification e.g. libisl
- `alltrafos`: pulls in additional dependencies for loop simplification e.g. libisl
- `bench_db`: functionality to store benchmark result in object databases
- `bench_db`: functionality to store benchmark result in object databases
- `interactive`: installs dependencies to work in Jupyter including image I/O, plotting etc.
- `interactive`: installs dependencies to work in Jupyter including image I/O, plotting etc.
@@ -63,7 +63,7 @@ Options can be combined e.g.
pip install pystencils[interactive, gpu, doc]
pip install pystencils[interactive, gpu, doc]
```
```


pystencils is also fully compatible with Windows machines. If working with visual studio and pycuda makes sure to run example files first to ensure that pycuda can find the compiler's executable.
pystencils is also fully compatible with Windows machines. If working with visual studio and cupy makes sure to run example files first to ensure that cupy can find the compiler's executable.


Documentation
Documentation
-------------
-------------
@@ -82,3 +82,6 @@ If you use pystencils in a publication, please cite the following articles:


Overview:
Overview:
  - M. Bauer et al, Code Generation for Massively Parallel Phase-Field Simulations. Association for Computing Machinery, 2019. https://doi.org/10.1145/3295500.3356186
  - M. Bauer et al, Code Generation for Massively Parallel Phase-Field Simulations. Association for Computing Machinery, 2019. https://doi.org/10.1145/3295500.3356186

Performance Modelling:
  - D. Ernst et al, Analytical performance estimation during code generation on modern GPUs. Journal of Parallel and Distributed Computing, 2023. https://doi.org/10.1016/j.jpdc.2022.11.003
Original line number Original line Diff line number Diff line
@@ -7,7 +7,7 @@
#     conda env create -f conda_environment_user.yml
#     conda env create -f conda_environment_user.yml
#     . activate pystencils
#     . activate pystencils
#
#
# If you have CUDA installed and want to use your GPU, uncomment the last line to install pycuda
# If you have CUDA or ROCm installed and want to use your GPU, uncomment the last line to install cupy
#
#
# ----------------------------------------------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------------------------------------


@@ -32,4 +32,4 @@ dependencies:
      - ipy_table  # HTML tables for jupyter notebooks
      - ipy_table  # HTML tables for jupyter notebooks
      - pyevtk # VTK output for serial simulations
      - pyevtk # VTK output for serial simulations
      - blitzdb # file-based No-SQL database to store simulation results
      - blitzdb # file-based No-SQL database to store simulation results
      #- pycuda # add this if you have CUDA installed
      #- cupy # add this if you have CUDA or ROCm installed
+16 −19
Original line number Original line Diff line number Diff line
@@ -8,7 +8,7 @@ import nbformat
import pytest
import pytest
from nbconvert import PythonExporter
from nbconvert import PythonExporter


from pystencils.boundaries.createindexlistcython import *  # NOQA
from pystencils.boundaries.createindexlist import *  # NOQA
# Trigger config file reading / creation once - to avoid race conditions when multiple instances are creating it
# Trigger config file reading / creation once - to avoid race conditions when multiple instances are creating it
# at the same time
# at the same time
from pystencils.cpu import cpujit
from pystencils.cpu import cpujit
@@ -40,51 +40,48 @@ def add_path_to_ignore(path):




collect_ignore = [os.path.join(SCRIPT_FOLDER, "doc", "conf.py"),
collect_ignore = [os.path.join(SCRIPT_FOLDER, "doc", "conf.py"),
                  os.path.join(SCRIPT_FOLDER, "pystencils", "opencl", "opencl.autoinit")]
                  os.path.join(SCRIPT_FOLDER, "src", "pystencils", "opencl", "opencl.autoinit")]
add_path_to_ignore('pystencils_tests/benchmark')
add_path_to_ignore('tests/benchmark')
add_path_to_ignore('_local_tmp')
add_path_to_ignore('_local_tmp')




try:
try:
    import pycuda
    import cupy
except ImportError:
except ImportError:
    collect_ignore += [os.path.join(SCRIPT_FOLDER, "pystencils_tests/test_cudagpu.py")]
    collect_ignore += [os.path.join(SCRIPT_FOLDER, "tests/test_gpu.py")]
    add_path_to_ignore('pystencils/gpucuda')
    add_path_to_ignore('src/pystencils/gpu')


try:
try:
    import waLBerla
    import waLBerla
except ImportError:
except ImportError:
    collect_ignore += [os.path.join(SCRIPT_FOLDER, "pystencils_tests/test_aligned_array.py"),
    collect_ignore += [os.path.join(SCRIPT_FOLDER, "tests/test_aligned_array.py"),
                       os.path.join(SCRIPT_FOLDER, "pystencils_tests/test_datahandling_parallel.py"),
                       os.path.join(SCRIPT_FOLDER, "tests/test_datahandling_parallel.py"),
                       os.path.join(SCRIPT_FOLDER, "doc/notebooks/03_tutorial_datahandling.ipynb"),
                       os.path.join(SCRIPT_FOLDER, "doc/notebooks/03_tutorial_datahandling.ipynb"),
                       os.path.join(SCRIPT_FOLDER, "pystencils/datahandling/parallel_datahandling.py"),
                       os.path.join(SCRIPT_FOLDER, "src/pystencils/datahandling/parallel_datahandling.py"),
                       os.path.join(SCRIPT_FOLDER, "pystencils_tests/test_small_block_benchmark.ipynb")]
                       os.path.join(SCRIPT_FOLDER, "tests/test_small_block_benchmark.ipynb")]


try:
try:
    import blitzdb
    import blitzdb
except ImportError:
except ImportError:
    add_path_to_ignore('pystencils/runhelper')
    add_path_to_ignore('src/pystencils/runhelper')
    collect_ignore += [os.path.join(SCRIPT_FOLDER, "pystencils_tests/test_parameterstudy.py")]
    collect_ignore += [os.path.join(SCRIPT_FOLDER, "tests/test_parameterstudy.py")]
    collect_ignore += [os.path.join(SCRIPT_FOLDER, "tests/test_json_serializer.py")]


try:
try:
    import islpy
    import islpy
except ImportError:
except ImportError:
    collect_ignore += [os.path.join(SCRIPT_FOLDER, "pystencils/integer_set_analysis.py")]
    collect_ignore += [os.path.join(SCRIPT_FOLDER, "src/pystencils/integer_set_analysis.py")]


try:
try:
    import graphviz
    import graphviz
except ImportError:
except ImportError:
    collect_ignore += [os.path.join(SCRIPT_FOLDER, "pystencils/backends/dot.py")]
    collect_ignore += [os.path.join(SCRIPT_FOLDER, "src/pystencils/backends/dot.py")]
    collect_ignore += [os.path.join(SCRIPT_FOLDER, "doc/notebooks/01_tutorial_getting_started.ipynb")]
    collect_ignore += [os.path.join(SCRIPT_FOLDER, "doc/notebooks/01_tutorial_getting_started.ipynb")]


try:
try:
    import pyevtk
    import pyevtk
except ImportError:
except ImportError:
    collect_ignore += [os.path.join(SCRIPT_FOLDER, "pystencils/datahandling/vtk.py")]
    collect_ignore += [os.path.join(SCRIPT_FOLDER, "src/pystencils/datahandling/vtk.py")]

# TODO: Remove if Ubuntu 18.04 is no longer supported
if pytest_version < 50403:
    collect_ignore += [os.path.join(SCRIPT_FOLDER, "pystencils_tests/test_jupyter_extensions.ipynb")]


collect_ignore += [os.path.join(SCRIPT_FOLDER, 'setup.py')]
collect_ignore += [os.path.join(SCRIPT_FOLDER, 'setup.py')]


doc/conf.py

100644 → 100755
+3 −3
Original line number Original line Diff line number Diff line
@@ -26,14 +26,14 @@ templates_path = ['_templates']
source_suffix = '.rst'
source_suffix = '.rst'
master_doc = 'index'
master_doc = 'index'


copyright = f'{datetime.datetime.now().year}, Martin Bauer'
copyright = f'{datetime.datetime.now().year}, Martin Bauer, Markus Holzer, Frederik Hennig'
author = 'Martin Bauer'
author = 'Martin Bauer, Markus Holzer, Frederik Hennig'
# The short X.Y version (including .devXXXX, rcX, b1 suffixes if present)
# The short X.Y version (including .devXXXX, rcX, b1 suffixes if present)
version = re.sub(r'(\d+\.\d+)\.\d+(.*)', r'\1\2', pystencils.__version__)
version = re.sub(r'(\d+\.\d+)\.\d+(.*)', r'\1\2', pystencils.__version__)
version = re.sub(r'(\.dev\d+).*?$', r'\1', version)
version = re.sub(r'(\.dev\d+).*?$', r'\1', version)
# The full version, including alpha/beta/rc tags.
# The full version, including alpha/beta/rc tags.
release = pystencils.__version__
release = pystencils.__version__
language = None
language = 'en'
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '**.ipynb_checkpoints']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '**.ipynb_checkpoints']
default_role = 'any'
default_role = 'any'
pygments_style = 'sphinx'
pygments_style = 'sphinx'
Original line number Original line Diff line number Diff line
@@ -11,11 +11,11 @@ Creating kernels
.. autoclass:: pystencils.CreateKernelConfig
.. autoclass:: pystencils.CreateKernelConfig
    :members:
    :members:


.. autofunction:: pystencils.create_domain_kernel
.. autofunction:: pystencils.kernelcreation.create_domain_kernel


.. autofunction:: pystencils.create_indexed_kernel
.. autofunction:: pystencils.kernelcreation.create_indexed_kernel


.. autofunction:: pystencils.create_staggered_kernel
.. autofunction:: pystencils.kernelcreation.create_staggered_kernel




Code printing
Code printing
@@ -27,11 +27,11 @@ Code printing
GPU Indexing
GPU Indexing
-------------
-------------


.. autoclass:: pystencils.gpucuda.AbstractIndexing
.. autoclass:: pystencils.gpu.AbstractIndexing
   :members:
   :members:


.. autoclass:: pystencils.gpucuda.BlockIndexing
.. autoclass:: pystencils.gpu.BlockIndexing
   :members:
   :members:


.. autoclass:: pystencils.gpucuda.LineIndexing
.. autoclass:: pystencils.gpu.LineIndexing
   :members:
   :members:

pyproject.toml

0 → 100644
+98 −0
Original line number Original line Diff line number Diff line
[project]
name = "pystencils"
description = "Speeding up stencil computations on CPUs and GPUs"
dynamic = ["version"]
readme = "README.md"
authors = [
    { name = "Martin Bauer" },
    { name = "Jan Hönig " },
    { name = "Markus Holzer" },
    { name = "Frederik Hennig" },
    { email = "cs10-codegen@fau.de" },
]
license = { file = "COPYING.txt" }
requires-python = ">=3.10"
dependencies = ["sympy>=1.9,<=1.12.1", "numpy>=1.8.0", "appdirs", "joblib", "pyyaml", "fasteners"]
classifiers = [
    "Development Status :: 4 - Beta",
    "Framework :: Jupyter",
    "Topic :: Software Development :: Code Generators",
    "Topic :: Scientific/Engineering :: Physics",
    "Intended Audience :: Developers",
    "Intended Audience :: Science/Research",
    "License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)",
]

[project.urls]
"Bug Tracker" = "https://i10git.cs.fau.de/pycodegen/pystencils/-/issues"
"Documentation" = "https://pycodegen.pages.i10git.cs.fau.de/pystencils/"
"Source Code" = "https://i10git.cs.fau.de/pycodegen/pystencils"

[project.optional-dependencies]
gpu = ['cupy']
alltrafos = ['islpy', 'py-cpuinfo']
bench_db = ['blitzdb', 'pymongo', 'pandas']
interactive = [
    'matplotlib',
    'ipy_table',
    'imageio',
    'jupyter',
    'pyevtk',
    'rich',
    'graphviz',
]
use_cython = [
    'Cython'
]
doc = [
    'sphinx',
    'sphinx_rtd_theme',
    'nbsphinx',
    'sphinxcontrib-bibtex',
    'sphinx_autodoc_typehints',
    'pandoc',
]
tests = [
    'pytest',
    'pytest-cov',
    'pytest-html',
    'ansi2html',
    'pytest-xdist',
    'flake8',
    'nbformat',
    'nbconvert',
    'ipython',
    'matplotlib',
    'py-cpuinfo',
    'randomgen>=1.18',
]

[build-system]
requires = [
    "setuptools>=61",
    "versioneer[toml]>=0.29",
    # 'Cython'
]
build-backend = "setuptools.build_meta"

[tool.setuptools.package-data]
pystencils = [
    "include/*.h",
    "boundaries/createindexlistcython.pyx"
]

[tool.setuptools.packages.find]
where = ["src"]
include = ["pystencils", "pystencils.*"]
namespaces = false

[tool.versioneer]
# See the docstring in versioneer.py for instructions. Note that you must
# re-run 'versioneer.py setup' after changing this section, and commit the
# resulting files.
VCS = "git"
style = "pep440"
versionfile_source = "src/pystencils/_version.py"
versionfile_build = "pystencils/_version.py"
tag_prefix = "release/"
parentdir_prefix = "pystencils-"
+0 −294
Original line number Original line Diff line number Diff line
__prof_trigger
printf

__syncthreads
__syncthreads_count
__syncthreads_and
__syncthreads_or
__syncwarp
__threadfence
__threadfence_block
__threadfence_system

atomicAdd
atomicSub
atomicExch
atomicMin
atomicMax
atomicInc
atomicDec
atomicAnd
atomicOr
atomicXor
atomicCAS

__all_sync
__any_sync
__ballot_sync
__active_mask

__shfl_sync
__shfl_up_sync
__shfl_down_sync
__shfl_xor_sync

__match_any_sync
__match_all_sync

__isGlobal
__isShared
__isConstant
__isLocal

tex1Dfetch
tex1D
tex2D
tex3D

sqrtf
rsqrtf
cbrtf
rcbrtf
hypotf
rhypotf
norm3df
rnorm3df
norm4df
rnorm4df
normf
rnormf
expf
exp2f
exp10f
expm1f
logf
log2f
log10f
log1pf
sinf
cosf
tanf
sincosf
sinpif
cospif
sincospif
asinf
acosf
atanf
atan2f
sinhf
coshf
tanhf
asinhf
acoshf
atanhf
powf
erff
erfcf
erfinvf
erfcinvf
erfcxf
normcdff
normcdfinvf
lgammaf
tgammaf
fmaf
frexpf
ldexpf
scalbnf
scalblnf
logbf
ilogbf
j0f
j1f
jnf
y0f
y1f
ynf
cyl_bessel_i0f
cyl_bessel_i1f
fmodf
remainderf
remquof
modff
fdimf
truncf
roundf
rintf
nearbyintf
ceilf
floorf
lrintf
lroundf
llrintf
llroundf

sqrt
rsqrt
cbrt
rcbrt
hypot
rhypot
norm3d
rnorm3d
norm4d
rnorm4d
norm
rnorm
exp
exp2
exp10
expm1
log
log2
log10
log1p
sin
cos
tan
sincos
sinpi
cospi
sincospi
asin
acos
atan
atan2
sinh
cosh
tanh
asinh
acosh
atanh
pow
erf
erfc
erfinv
erfcinv
erfcx
normcdf
normcdfinv
lgamma
tgamma
fma
frexp
ldexp
scalbn
scalbln
logb
ilogb
j0
j1
jn
y0
y1
yn
cyl_bessel_i0
cyl_bessel_i1
fmod
remainder
remquo
mod
fdim
trunc
round
rint
nearbyint
ceil
floor
lrint
lround
llrint
llround

__fdividef
__sinf
__cosf
__tanf
__sincosf
__logf
__log2f
__log10f
__expf
__exp10f
__powf

__fadd_rn
__fsub_rn
__fmul_rn
__fmaf_rn
__frcp_rn
__fsqrt_rn
__frsqrt_rn
__fdiv_rn

__fadd_rz
__fsub_rz
__fmul_rz
__fmaf_rz
__frcp_rz
__fsqrt_rz
__frsqrt_rz
__fdiv_rz

__fadd_ru
__fsub_ru
__fmul_ru
__fmaf_ru
__frcp_ru
__fsqrt_ru
__frsqrt_ru
__fdiv_ru

__fadd_rd
__fsub_rd
__fmul_rd
__fmaf_rd
__frcp_rd
__fsqrt_rd
__frsqrt_rd
__fdiv_rd

__fdividef
__expf
__exp10f
__logf
__log2f
__log10f
__sinf
__cosf
__sincosf
__tanf
__powf

__dadd_rn
__dsub_rn
__dmul_rn
__fma_rn
__ddiv_rn
__drcp_rn
__dsqrt_rn

__dadd_rz
__dsub_rz
__dmul_rz
__fma_rz
__ddiv_rz
__drcp_rz
__dsqrt_rz

__dadd_ru
__dsub_ru
__dmul_ru
__fma_ru
__ddiv_ru
__drcp_ru
__dsqrt_ru

__dadd_rd
__dsub_rd
__dmul_rd
__fma_rd
__ddiv_rd
__drcp_rd
__dsqrt_rd

pystencils/data_types.py

deleted100644 → 0
+0 −814

File deleted.

Preview size limit exceeded, changes collapsed.

pystencils/datahandling/pycuda.py

deleted100644 → 0
+0 −52
Original line number Original line Diff line number Diff line
try:
    import pycuda.gpuarray as gpuarray
except ImportError:
    gpuarray = None
import numpy as np

import pystencils


class PyCudaArrayHandler:

    def __init__(self):
        import pycuda.autoinit  # NOQA

    def zeros(self, shape, dtype=np.float64, order='C'):
        cpu_array = np.zeros(shape=shape, dtype=dtype, order=order)
        return self.to_gpu(cpu_array)

    def ones(self, shape, dtype=np.float64, order='C'):
        cpu_array = np.ones(shape=shape, dtype=dtype, order=order)
        return self.to_gpu(cpu_array)

    def empty(self, shape, dtype=np.float64, layout=None):
        if layout:
            cpu_array = pystencils.field.create_numpy_array_with_layout(shape=shape, dtype=dtype, layout=layout)
            return self.to_gpu(cpu_array)
        else:
            return gpuarray.empty(shape, dtype)

    @staticmethod
    def to_gpu(array):
        return gpuarray.to_gpu(array)

    @staticmethod
    def upload(array, numpy_array):
        array.set(numpy_array)

    @staticmethod
    def download(array, numpy_array):
        array.get(numpy_array)

    def randn(self, shape, dtype=np.float64):
        cpu_array = np.random.randn(*shape).astype(dtype)
        return self.to_gpu(cpu_array)

    from_numpy = to_gpu


class PyCudaNotAvailableHandler:
    def __getattribute__(self, name):
        raise NotImplementedError("Unable to initiaize PyCuda! "
                                  "Try to run `import pycuda.autoinit` to check whether PyCuda is working correctly!")
+0 −19
Original line number Original line Diff line number Diff line
#pragma once

extern "C++" {
#ifdef __CUDA_ARCH__
template <typename DTYPE_T, std::size_t DIMENSION> struct PyStencilsField {
  DTYPE_T *data;
  DTYPE_T shape[DIMENSION];
  DTYPE_T stride[DIMENSION];
};
#else
#include <array>

template <typename DTYPE_T, std::size_t DIMENSION> struct PyStencilsField {
  DTYPE_T *data;
  std::array<DTYPE_T, DIMENSION> shape;
  std::array<DTYPE_T, DIMENSION> stride;
};
#endif
}
+0 −15
Original line number Original line Diff line number Diff line
#ifndef OPENCL_STDINT
#define OPENCL_STDINT

typedef unsigned int      uint_t;

typedef signed char       int8_t;
typedef signed short      int16_t;
typedef signed int        int32_t;
typedef signed long int   int64_t;
typedef unsigned char     uint8_t;
typedef unsigned short    uint16_t;
typedef unsigned int      uint32_t;
typedef unsigned long int uint64_t;

#endif
+0 −48
Original line number Original line Diff line number Diff line
"""
Test of pystencils.data_types.address_of
"""
import sympy as sp
import pystencils
from pystencils.data_types import PointerType, address_of, cast_func, create_type
from pystencils.simp.simplifications import sympy_cse


def test_address_of():
    x, y = pystencils.fields('x,y: int64[2d]')
    s = pystencils.TypedSymbol('s', PointerType(create_type('int64')))

    assert address_of(x[0, 0]).canonical() == x[0, 0]
    assert address_of(x[0, 0]).dtype == PointerType(x[0, 0].dtype, restrict=True)
    assert address_of(sp.Symbol("a")).dtype == PointerType('void', restrict=True)

    assignments = pystencils.AssignmentCollection({
        s: address_of(x[0, 0]),
        y[0, 0]: cast_func(s, create_type('int64'))
    }, {})

    ast = pystencils.create_kernel(assignments)
    pystencils.show_code(ast)

    assignments = pystencils.AssignmentCollection({
        y[0, 0]: cast_func(address_of(x[0, 0]), create_type('int64'))
    }, {})

    ast = pystencils.create_kernel(assignments)
    pystencils.show_code(ast)


def test_address_of_with_cse():
    x, y = pystencils.fields('x,y: int64[2d]')
    s = pystencils.TypedSymbol('s', PointerType(create_type('int64')))

    assignments = pystencils.AssignmentCollection({
        y[0, 0]: cast_func(address_of(x[0, 0]), create_type('int64')) + s,
        x[0, 0]: cast_func(address_of(x[0, 0]), create_type('int64')) + 1
    }, {})

    ast = pystencils.create_kernel(assignments)
    pystencils.show_code(ast)
    assignments_cse = sympy_cse(assignments)

    ast = pystencils.create_kernel(assignments_cse)
    pystencils.show_code(ast)
+0 −149
Original line number Original line Diff line number Diff line
# -*- coding: utf-8 -*-
#
# Copyright © 2019 Stephan Seitz <stephan.seitz@fau.de>
#
# Distributed under terms of the GPLv3 license.
"""

"""

import itertools

import numpy as np
import pytest
import sympy
from sympy.functions import im, re

import pystencils
from pystencils import AssignmentCollection
from pystencils.data_types import TypedSymbol, create_type

X, Y = pystencils.fields('x, y: complex64[2d]')
A, B = pystencils.fields('a, b: float32[2d]')
S1, S2, T = sympy.symbols('S1, S2, T')

TEST_ASSIGNMENTS = [
    AssignmentCollection({X[0, 0]: 1j}),
    AssignmentCollection({
        S1: re(Y.center),
        S2: im(Y.center),
        X[0, 0]: 2j * S1 + S2
    }),
    AssignmentCollection({
        A.center: re(Y.center),
        B.center: im(Y.center),
    }),
    AssignmentCollection({
        Y.center: re(Y.center) + X.center + 2j,
    }),
    AssignmentCollection({
        T: 2 + 4j,
        Y.center: X.center / T,
    })
]

SCALAR_DTYPES = ['float32', 'float64']


@pytest.mark.parametrize("assignment, scalar_dtypes",
                         itertools.product(TEST_ASSIGNMENTS, (np.float32,)))
@pytest.mark.parametrize('target', (pystencils.Target.CPU, pystencils.Target.GPU))
def test_complex_numbers(assignment, scalar_dtypes, target):
    ast = pystencils.create_kernel(assignment,
                                   target=target,
                                   data_type=scalar_dtypes)
    code = pystencils.get_code_str(ast)

    print(code)
    assert "Not supported" not in code

    if target == pystencils.Target.GPU:
        pytest.importorskip('pycuda')

    kernel = ast.compile()
    assert kernel is not None


X, Y = pystencils.fields('x, y: complex128[2d]')
A, B = pystencils.fields('a, b: float64[2d]')
S1, S2 = sympy.symbols('S1, S2')
T128 = TypedSymbol('ts', create_type('complex128'))

TEST_ASSIGNMENTS = [
    AssignmentCollection({X[0, 0]: 1j}),
    AssignmentCollection({
        S1: re(Y.center),
        S2: im(Y.center),
        X[0, 0]: 2j * S1 + S2
    }),
    AssignmentCollection({
        A.center: re(Y.center),
        B.center: im(Y.center),
    }),
    AssignmentCollection({
        Y.center: re(Y.center) + X.center + 2j,
    }),
    AssignmentCollection({
        T128: 2 + 4j,
        Y.center: X.center / T128,
    })
]

SCALAR_DTYPES = ['float64']


@pytest.mark.parametrize("assignment", TEST_ASSIGNMENTS)
@pytest.mark.parametrize('target', (pystencils.Target.CPU, pystencils.Target.GPU))
def test_complex_numbers_64(assignment, target):
    ast = pystencils.create_kernel(assignment,
                                   target=target,
                                   data_type='double')
    code = pystencils.get_code_str(ast)

    print(code)
    assert "Not supported" not in code

    if target == pystencils.Target.GPU:
        pytest.importorskip('pycuda')

    kernel = ast.compile()
    assert kernel is not None


@pytest.mark.parametrize('dtype', (np.float32, np.float64))
@pytest.mark.parametrize('target', (pystencils.Target.CPU, pystencils.Target.GPU))
@pytest.mark.parametrize('with_complex_argument', ('with_complex_argument', False))
def test_complex_execution(dtype, target, with_complex_argument):

    complex_dtype = f'complex{64 if dtype ==np.float32 else 128}'
    x, y = pystencils.fields(f'x, y:  {complex_dtype}[2d]')

    x_arr = np.zeros((20, 30), complex_dtype)
    y_arr = np.zeros((20, 30), complex_dtype)

    if with_complex_argument:
        a = pystencils.TypedSymbol('a', create_type(complex_dtype))
    else:
        a = (2j+1)

    assignments = AssignmentCollection({
        y.center: x.center + a
    })

    if target == pystencils.Target.GPU:
        pytest.importorskip('pycuda')
        from pycuda.gpuarray import zeros
        x_arr = zeros((20, 30), complex_dtype)
        y_arr = zeros((20, 30), complex_dtype)

    kernel = pystencils.create_kernel(assignments, target=target, data_type=dtype).compile()

    if with_complex_argument:
        kernel(x=x_arr, y=y_arr, a=2j+1)
    else:
        kernel(x=x_arr, y=y_arr)

    if target == pystencils.Target.GPU:
        y_arr = y_arr.get()
    assert np.allclose(y_arr, 2j+1)
Original line number Original line Diff line number Diff line
import pytest

import pystencils as ps
import numpy as np


# This test aims to trigger deprication warnings. Thus the warnings should not be displayed in the warning summary.
def test_create_kernel_backwards_compatibility():
    size = (30, 20)

    src_field_string = np.random.rand(*size)
    src_field_enum = np.copy(src_field_string)
    src_field_config = np.copy(src_field_string)
    dst_field_string = np.zeros(size)
    dst_field_enum = np.zeros(size)
    dst_field_config = np.zeros(size)

    f = ps.Field.create_from_numpy_array("f", src_field_enum)
    d = ps.Field.create_from_numpy_array("d", dst_field_enum)

    jacobi = ps.Assignment(d[0, 0], (f[1, 0] + f[-1, 0] + f[0, 1] + f[0, -1]) / 4)
    ast_enum = ps.create_kernel(jacobi, target=ps.Target.CPU).compile()
    with pytest.warns(DeprecationWarning):
        ast_string = ps.create_kernel(jacobi, target='cpu').compile()
    # noinspection PyTypeChecker
    with pytest.warns(DeprecationWarning):
        ast_config = ps.create_kernel(jacobi, config=ps.CreateKernelConfig(target='cpu')).compile()
    ast_enum(f=src_field_enum, d=dst_field_enum)
    ast_string(f=src_field_string, d=dst_field_string)
    ast_config(f=src_field_config, d=dst_field_config)

    error = np.sum(np.abs(dst_field_enum - dst_field_string))
    np.testing.assert_almost_equal(error, 0.0)
    error = np.sum(np.abs(dst_field_enum - dst_field_config))
    np.testing.assert_almost_equal(error, 0.0)
+0 −50
Original line number Original line Diff line number Diff line
import sympy

import pytest

import pystencils
from pystencils.astnodes import get_dummy_symbol
from pystencils.backends.cuda_backend import CudaSympyPrinter
from pystencils.data_types import address_of
from pystencils.enums import Target


def test_cuda_known_functions():
    printer = CudaSympyPrinter()
    print(printer.known_functions)

    x, y = pystencils.fields('x,y: float32 [2d]')

    assignments = pystencils.AssignmentCollection({
        get_dummy_symbol(): sympy.Function('atomicAdd')(address_of(y.center()), 2),
        y.center():  sympy.Function('rsqrtf')(x[0, 0])
    })

    ast = pystencils.create_kernel(assignments, target=Target.GPU)
    pytest.importorskip('pycuda')
    pystencils.show_code(ast)
    kernel = ast.compile()
    assert(kernel is not None)


def test_cuda_but_not_c():
    x, y = pystencils.fields('x,y: float32 [2d]')

    assignments = pystencils.AssignmentCollection({
        get_dummy_symbol(): sympy.Function('atomicAdd')(address_of(y.center()), 2),
        y.center():  sympy.Function('rsqrtf')(x[0, 0])
    })

    ast = pystencils.create_kernel(assignments, target=Target.CPU)
    pystencils.show_code(ast)


def test_cuda_unknown():
    x, y = pystencils.fields('x,y: float32 [2d]')

    assignments = pystencils.AssignmentCollection({
        get_dummy_symbol(): sympy.Function('wtf')(address_of(y.center()), 2),
    })

    ast = pystencils.create_kernel(assignments, target=Target.GPU)
    pystencils.show_code(ast)
+0 −36
Original line number Original line Diff line number Diff line
%% Cell type:code id: tags:

``` python
import pytest
pytest.importorskip('graphviz')
```

%% Cell type:code id: tags:

``` python
from pystencils.session import *
from pystencils.astnodes import Block, Conditional
```

%% Cell type:code id: tags:

``` python
src, dst = ps.fields("src, dst: double[2D]", layout='c')

true_block = Block([ps.Assignment(dst[0, 0], src[-1, 0])])
false_block = Block([ps.Assignment(dst[0, 0], src[1, 0])])
ur = [true_block, Conditional(dst.center() > 0.0, true_block, false_block)]

ast = ps.create_kernel(ur)
```

%% Cell type:code id: tags:

``` python
ps.to_dot(ast, graph_style={'size': "9.5,12.5"})
```

%% Output

img src="data:image/svg+xml;utf8,<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN""http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><!-- Generated by graphviz version 2.40.1 (20161225.0304)--><!-- Title: %3 Pages: 1 --><svg width="684pt" height="290pt"viewBox="0.00 0.00 684.00 289.51" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><g id="graph0" class="graph" transform="scale(.4128 .4128) rotate(0) translate(4 697.3797)"><title>%3</title><polygon fill="#ffffff" stroke="transparent" points="-4,4 -4,-697.3797 1653.0784,-697.3797 1653.0784,4 -4,4"/><!-- 140060050351120 --><g id="node1" class="node"><title>140060050351120</title><ellipse fill="#a056db" stroke="#000000" cx="243.1436" cy="-675.3797" rx="111.5806" ry="18"/><text text-anchor="middle" x="243.1436" y="-671.6797" font-family="Times,serif" font-size="14.00" fill="#000000">Func: kernel (dst,src)</text></g><!-- 140060034299536 --><g id="node19" class="node"><title>140060034299536</title><ellipse fill="#dbc256" stroke="#000000" cx="243.1436" cy="-603.3797" rx="37.0935" ry="18"/><text text-anchor="middle" x="243.1436" y="-599.6797" font-family="Times,serif" font-size="14.00" fill="#000000">Block</text></g><!-- 140060050351120&#45;&gt;140060034299536 --><g id="edge18" class="edge"><title>140060050351120&#45;&gt;140060034299536</title><path fill="none" stroke="#000000" d="M243.1436,-657.2111C243.1436,-649.5107 243.1436,-640.3541 243.1436,-631.7964"/><polygon fill="#000000" stroke="#000000" points="246.6437,-631.793 243.1436,-621.793 239.6437,-631.793 246.6437,-631.793"/></g><!-- 140060034299984 --><g id="node2" class="node"><title>140060034299984</title><ellipse fill="#3498db" stroke="#000000" cx="243.1436" cy="-531.3797" rx="86.3847" ry="18"/><text text-anchor="middle" x="243.1436" y="-527.6797" font-family="Times,serif" font-size="14.00" fill="#000000">Loop over dim 0</text></g><!-- 140060034299664 --><g id="node18" class="node"><title>140060034299664</title><ellipse fill="#dbc256" stroke="#000000" cx="243.1436" cy="-459.3797" rx="37.0935" ry="18"/><text text-anchor="middle" x="243.1436" y="-455.6797" font-family="Times,serif" font-size="14.00" fill="#000000">Block</text></g><!-- 140060034299984&#45;&gt;140060034299664 --><g id="edge16" class="edge"><title>140060034299984&#45;&gt;140060034299664</title><path fill="none" stroke="#000000" d="M243.1436,-513.2111C243.1436,-505.5107 243.1436,-496.3541 243.1436,-487.7964"/><polygon fill="#000000" stroke="#000000" points="246.6437,-487.793 243.1436,-477.793 239.6437,-487.793 246.6437,-487.793"/></g><!-- 140060034380240 --><g id="node3" class="node"><title>140060034380240</title><ellipse fill="#56db7f" stroke="#000000" cx="72.1436" cy="-387.3797" rx="72.2875" ry="18"/><text text-anchor="middle" x="72.1436" y="-383.6797" font-family="Times,serif" font-size="14.00" fill="#000000">_data_dst_00</text></g><!-- 140060034381584 --><g id="node4" class="node"><title>140060034381584</title><ellipse fill="#56db7f" stroke="#000000" cx="243.1436" cy="-387.3797" rx="81.4863" ry="18"/><text text-anchor="middle" x="243.1436" y="-383.6797" font-family="Times,serif" font-size="14.00" fill="#000000">_data_src_0m1</text></g><!-- 140060034300688 --><g id="node5" class="node"><title>140060034300688</title><ellipse fill="#3498db" stroke="#000000" cx="429.1436" cy="-387.3797" rx="86.3847" ry="18"/><text text-anchor="middle" x="429.1436" y="-383.6797" font-family="Times,serif" font-size="14.00" fill="#000000">Loop over dim 1</text></g><!-- 140060034298960 --><g id="node17" class="node"><title>140060034298960</title><ellipse fill="#dbc256" stroke="#000000" cx="429.1436" cy="-315.3797" rx="37.0935" ry="18"/><text text-anchor="middle" x="429.1436" y="-311.6797" font-family="Times,serif" font-size="14.00" fill="#000000">Block</text></g><!-- 140060034300688&#45;&gt;140060034298960 --><g id="edge12" class="edge"><title>140060034300688&#45;&gt;140060034298960</title><path fill="none" stroke="#000000" d="M429.1436,-369.2111C429.1436,-361.5107 429.1436,-352.3541 429.1436,-343.7964"/><polygon fill="#000000" stroke="#000000" points="432.6437,-343.793 429.1436,-333.793 425.6437,-343.793 432.6437,-343.793"/></g><!-- 140060034298192 --><g id="node6" class="node"><title>140060034298192</title><ellipse fill="#56db7f" stroke="#000000" cx="203.1436" cy="-202.6899" rx="170.8697" ry="18"/><text text-anchor="middle" x="203.1436" y="-198.9899" font-family="Times,serif" font-size="14.00" fill="#000000">_data_dst_00[_stride_dst_1*ctr_1]</text></g><!-- 140060165603728 --><g id="node7" class="node"><title>140060165603728</title><ellipse fill="#dbc256" stroke="#000000" cx="429.1436" cy="-202.6899" rx="37.0935" ry="18"/><text text-anchor="middle" x="429.1436" y="-198.9899" font-family="Times,serif" font-size="14.00" fill="#000000">Block</text></g><!-- 140060034299472 --><g id="node8" class="node"><title>140060034299472</title><ellipse fill="#56bd7f" stroke="#000000" cx="857.1436" cy="-202.6899" rx="372.7906" ry="58.8803"/><text text-anchor="middle" x="857.1436" y="-228.9899" font-family="Times,serif" font-size="14.00" fill="#000000">else: </text><text text-anchor="middle" x="857.1436" y="-213.9899" font-family="Times,serif" font-size="14.00" fill="#000000"> Block _data_dst_00 ← _data_dst + _stride_dst_0*ctr_0</text><text text-anchor="middle" x="857.1436" y="-198.9899" font-family="Times,serif" font-size="14.00" fill="#000000">_data_src_01 ← _data_src + _stride_src_0*ctr_0 + _stride_src_0</text><text text-anchor="middle" x="857.1436" y="-183.9899" font-family="Times,serif" font-size="14.00" fill="#000000">_data_dst_00[_stride_dst_1*ctr_1] ← _data_src_01[_stride_src_1*ctr_1]</text><text text-anchor="middle" x="857.1436" y="-168.9899" font-family="Times,serif" font-size="14.00" fill="#000000"> </text></g><!-- 140060037556304 --><g id="node12" class="node"><title>140060037556304</title><ellipse fill="#dbc256" stroke="#000000" cx="659.1436" cy="-90" rx="37.0935" ry="18"/><text text-anchor="middle" x="659.1436" y="-86.3" font-family="Times,serif" font-size="14.00" fill="#000000">Block</text></g><!-- 140060034299472&#45;&gt;140060037556304 --><g id="edge4" class="edge"><title>140060034299472&#45;&gt;140060037556304</title><path fill="none" stroke="#000000" d="M757.5635,-146.0148C733.9458,-132.573 710.3721,-119.1562 692.2192,-108.8247"/><polygon fill="#000000" stroke="#000000" points="693.6713,-105.624 683.249,-103.7194 690.2088,-111.7077 693.6713,-105.624"/></g><!-- 140060034298640 --><g id="node16" class="node"><title>140060034298640</title><ellipse fill="#dbc256" stroke="#000000" cx="1136.1436" cy="-90" rx="37.0935" ry="18"/><text text-anchor="middle" x="1136.1436" y="-86.3" font-family="Times,serif" font-size="14.00" fill="#000000">Block</text></g><!-- 140060034299472&#45;&gt;140060034298640 --><g id="edge8" class="edge"><title>140060034299472&#45;&gt;140060034298640</title><path fill="none" stroke="#000000" d="M992.5572,-147.9955C1031.2605,-132.3629 1070.3836,-116.5609 1097.9961,-105.408"/><polygon fill="#000000" stroke="#000000" points="1099.6649,-108.5088 1107.6263,-101.5183 1097.0432,-102.0182 1099.6649,-108.5088"/></g><!-- 140060034382224 --><g id="node9" class="node"><title>140060034382224</title><ellipse fill="#56db7f" stroke="#000000" cx="353.1436" cy="-18" rx="72.2875" ry="18"/><text text-anchor="middle" x="353.1436" y="-14.3" font-family="Times,serif" font-size="14.00" fill="#000000">_data_dst_00</text></g><!-- 140060044051536 --><g id="node10" class="node"><title>140060044051536</title><ellipse fill="#56db7f" stroke="#000000" cx="524.1436" cy="-18" rx="81.4863" ry="18"/><text text-anchor="middle" x="524.1436" y="-14.3" font-family="Times,serif" font-size="14.00" fill="#000000">_data_src_0m1</text></g><!-- 140060034298704 --><g id="node11" class="node"><title>140060034298704</title><ellipse fill="#56db7f" stroke="#000000" cx="794.1436" cy="-18" rx="170.8697" ry="18"/><text text-anchor="middle" x="794.1436" y="-14.3" font-family="Times,serif" font-size="14.00" fill="#000000">_data_dst_00[_stride_dst_1*ctr_1]</text></g><!-- 140060037556304&#45;&gt;140060034382224 --><g id="edge1" class="edge"><title>140060037556304&#45;&gt;140060034382224</title><path fill="none" stroke="#000000" d="M625.5209,-82.0888C575.1201,-70.2298 479.132,-47.6443 415.6277,-32.7021"/><polygon fill="#000000" stroke="#000000" points="416.2623,-29.256 405.7265,-30.3724 414.659,-36.0699 416.2623,-29.256"/></g><!-- 140060037556304&#45;&gt;140060044051536 --><g id="edge2" class="edge"><title>140060037556304&#45;&gt;140060044051536</title><path fill="none" stroke="#000000" d="M634.0675,-76.6261C614.6322,-66.2606 587.3057,-51.6865 564.7614,-39.6628"/><polygon fill="#000000" stroke="#000000" points="566.2191,-36.4736 555.7485,-34.8559 562.9249,-42.6501 566.2191,-36.4736"/></g><!-- 140060037556304&#45;&gt;140060034298704 --><g id="edge3" class="edge"><title>140060037556304&#45;&gt;140060034298704</title><path fill="none" stroke="#000000" d="M684.2197,-76.6261C703.1859,-66.5108 729.6668,-52.3876 751.8851,-40.5378"/><polygon fill="#000000" stroke="#000000" points="753.6187,-43.58 760.7951,-35.7858 750.3245,-37.4035 753.6187,-43.58"/></g><!-- 140060034383312 --><g id="node13" class="node"><title>140060034383312</title><ellipse fill="#56db7f" stroke="#000000" cx="1055.1436" cy="-18" rx="72.2875" ry="18"/><text text-anchor="middle" x="1055.1436" y="-14.3" font-family="Times,serif" font-size="14.00" fill="#000000">_data_dst_00</text></g><!-- 140060034383184 --><g id="node14" class="node"><title>140060034383184</title><ellipse fill="#56db7f" stroke="#000000" cx="1217.1436" cy="-18" rx="72.2875" ry="18"/><text text-anchor="middle" x="1217.1436" y="-14.3" font-family="Times,serif" font-size="14.00" fill="#000000">_data_src_01</text></g><!-- 140060034776592 --><g id="node15" class="node"><title>140060034776592</title><ellipse fill="#56db7f" stroke="#000000" cx="1478.1436" cy="-18" rx="170.8697" ry="18"/><text text-anchor="middle" x="1478.1436" y="-14.3" font-family="Times,serif" font-size="14.00" fill="#000000">_data_dst_00[_stride_dst_1*ctr_1]</text></g><!-- 140060034298640&#45;&gt;140060034383312 --><g id="edge5" class="edge"><title>140060034298640&#45;&gt;140060034383312</title><path fill="none" stroke="#000000" d="M1118.1671,-74.0209C1107.6147,-64.641 1094.0712,-52.6024 1082.2454,-42.0905"/><polygon fill="#000000" stroke="#000000" points="1084.5702,-39.4741 1074.7708,-35.4464 1079.9196,-44.706 1084.5702,-39.4741"/></g><!-- 140060034298640&#45;&gt;140060034383184 --><g id="edge6" class="edge"><title>140060034298640&#45;&gt;140060034383184</title><path fill="none" stroke="#000000" d="M1154.1201,-74.0209C1164.6724,-64.641 1178.216,-52.6024 1190.0418,-42.0905"/><polygon fill="#000000" stroke="#000000" points="1192.3675,-44.706 1197.5164,-35.4464 1187.717,-39.4741 1192.3675,-44.706"/></g><!-- 140060034298640&#45;&gt;140060034776592 --><g id="edge7" class="edge"><title>140060034298640&#45;&gt;140060034776592</title><path fill="none" stroke="#000000" d="M1170.1862,-82.8331C1221.3389,-72.0641 1319.6786,-51.3611 1391.5128,-36.2381"/><polygon fill="#000000" stroke="#000000" points="1392.4009,-39.6279 1401.4653,-34.1428 1390.9588,-32.778 1392.4009,-39.6279"/></g><!-- 140060034298960&#45;&gt;140060034298192 --><g id="edge9" class="edge"><title>140060034298960&#45;&gt;140060034298192</title><path fill="none" stroke="#000000" d="M403.2185,-302.4528C365.3624,-283.5767 294.424,-248.2048 247.9919,-225.0525"/><polygon fill="#000000" stroke="#000000" points="249.2741,-221.7809 238.7631,-220.4507 246.1504,-228.0453 249.2741,-221.7809"/></g><!-- 140060034298960&#45;&gt;140060165603728 --><g id="edge10" class="edge"><title>140060034298960&#45;&gt;140060165603728</title><path fill="none" stroke="#000000" d="M429.1436,-297.2741C429.1436,-279.3665 429.1436,-251.7016 429.1436,-230.9091"/><polygon fill="#000000" stroke="#000000" points="432.6437,-230.7505 429.1436,-220.7505 425.6437,-230.7505 432.6437,-230.7505"/></g><!-- 140060034298960&#45;&gt;140060034299472 --><g id="edge11" class="edge"><title>140060034298960&#45;&gt;140060034299472</title><path fill="none" stroke="#000000" d="M462.0174,-306.7243C504.2144,-295.614 580.9235,-275.417 655.6024,-255.7545"/><polygon fill="#000000" stroke="#000000" points="656.8664,-259.041 665.6456,-253.1101 655.084,-252.2717 656.8664,-259.041"/></g><!-- 140060034299664&#45;&gt;140060034380240 --><g id="edge13" class="edge"><title>140060034299664&#45;&gt;140060034380240</title><path fill="none" stroke="#000000" d="M214.9064,-447.4904C188.6863,-436.4503 149.1689,-419.8114 118.3532,-406.8364"/><polygon fill="#000000" stroke="#000000" points="119.668,-403.5924 109.0934,-402.9375 116.9515,-410.0439 119.668,-403.5924"/></g><!-- 140060034299664&#45;&gt;140060034381584 --><g id="edge14" class="edge"><title>140060034299664&#45;&gt;140060034381584</title><path fill="none" stroke="#000000" d="M243.1436,-441.2111C243.1436,-433.5107 243.1436,-424.3541 243.1436,-415.7964"/><polygon fill="#000000" stroke="#000000" points="246.6437,-415.793 243.1436,-405.793 239.6437,-415.793 246.6437,-415.793"/></g><!-- 140060034299664&#45;&gt;140060034300688 --><g id="edge15" class="edge"><title>140060034299664&#45;&gt;140060034300688</title><path fill="none" stroke="#000000" d="M272.2061,-448.1297C300.5974,-437.1396 344.3973,-420.1847 378.5179,-406.9768"/><polygon fill="#000000" stroke="#000000" points="379.802,-410.2329 387.8642,-403.3589 377.275,-403.7049 379.802,-410.2329"/></g><!-- 140060034299536&#45;&gt;140060034299984 --><g id="edge17" class="edge"><title>140060034299536&#45;&gt;140060034299984</title><path fill="none" stroke="#000000" d="M243.1436,-585.2111C243.1436,-577.5107 243.1436,-568.3541 243.1436,-559.7964"/><polygon fill="#000000" stroke="#000000" points="246.6437,-559.793 243.1436,-549.793 239.6437,-559.793 246.6437,-559.793"/></g></g></svg>">
    <graphviz.files.Source at 0x7f62452c4110>
+13 −10

File changed.

Preview size limit exceeded, changes collapsed.

quicktest.py

0 → 100644
+22 −0

File added.

Preview size limit exceeded, changes collapsed.

setup.cfg

deleted100644 → 0
+0 −11

File deleted.

Preview size limit exceeded, changes collapsed.

+13 −129

File changed.

Preview size limit exceeded, changes collapsed.

+209 −0

File added.

Preview size limit exceeded, changes collapsed.

+50 −0

File added.

Preview size limit exceeded, changes collapsed.