Skip to content
Snippets Groups Projects
Commit 0f0c203b authored by Martin Bauer's avatar Martin Bauer
Browse files

Separated modules into subfolders with own setup.py

This restructuring allows for easier separation of modules into
separate repositories later. Also, now pip install with repo url can be
used.

The setup.py files have also been updated to correctly reference each
other. Module versions are not extracted from git state
parent 1746fc01
No related merge requests found
File moved
File moved
File moved
File moved
File moved
import sympy as sp
import pystencils as ps
from pystencils_walberla import generate_sweep
from pystencils_walberla.cmake_integration import ManualCodeGenerationContext
try:
import pycuda
except ImportError:
pycuda = None
for openmp in (False, True):
for da in (False, True):
with ManualCodeGenerationContext(openmp=openmp, double_accuracy=da) as ctx:
h = sp.symbols("h")
dtype = "float64" if ctx.double_accuracy else "float32"
# ----- Jacobi 2D - created by specifying weights in nested list --------------------------
src, dst = ps.fields("src, src_tmp: {}[2D]".format(dtype))
stencil = [[0, -1, 0],
[-1, 4, -1],
[0, -1, 0]]
assignments = ps.assignment_from_stencil(stencil, src, dst, normalization_factor=4 * h**2)
generate_sweep(ctx, 'JacobiKernel2D', assignments, field_swaps=[(src, dst)])
# ----- Jacobi 3D - created by using kernel_decorator with assignments in '@=' format -----
src, dst = ps.fields("src, src_tmp: {}[3D]".format(dtype))
@ps.kernel
def kernel_func():
dst[0, 0, 0] @= (src[1, 0, 0] + src[-1, 0, 0] +
src[0, 1, 0] + src[0, -1, 0] +
src[0, 0, 1] + src[0, 0, -1]) / (6 * h ** 2)
generate_sweep(ctx, 'JacobiKernel3D', kernel_func, field_swaps=[(src, dst)])
expected_files = ('JacobiKernel3D.cpp', 'JacobiKernel3D.h',
'JacobiKernel2D.cpp', 'JacobiKernel2D.h')
assert all(e in ctx.files for e in expected_files)
for file_name_to_test in ('JacobiKernel3D.cpp', 'JacobiKernel2D.cpp'):
file_to_test = ctx.files[file_name_to_test]
if openmp:
assert '#pragma omp parallel' in file_to_test
if da:
assert 'float ' not in file_to_test
else:
assert 'double ' not in file_to_test
setup.py 0 → 100644
from setuptools import setup
setup(name='pystencils_walberla',
description='pystencils code generation for waLBerla apps',
author='Martin Bauer',
license='AGPLv3',
author_email='martin.bauer@fau.de',
url='https://i10git.cs.fau.de/software/pystencils/',
packages=['pystencils_walberla'],
install_requires=['pystencils[alltrafos]', 'jinja2'],
package_data={'pystencils_walberla': ['templates/*']},
version_format='{tag}.dev{commits}+{sha}',
)
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment