pystencils merge requestshttps://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests2020-01-21T21:59:42+01:00https://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/136Add typeannotations and docstring for KernelWrapper2020-01-21T21:59:42+01:00Stephan SeitzAdd typeannotations and docstring for KernelWrapperhttps://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/132let show_code display/print code2020-01-21T22:02:07+01:00Stephan Seitzlet show_code display/print code- `get_code_obj` will keep the previous behavior of `show_code`
- `get_code_str` will be equivalent to previous `str(show_code(...))`
Fixes #6- `get_code_obj` will keep the previous behavior of `show_code`
- `get_code_str` will be equivalent to previous `str(show_code(...))`
Fixes #6https://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/133Allow vector assignments2020-01-21T22:04:08+01:00Stephan SeitzAllow vector assignments```python
>>>import pystencils as ps
>>>import sympy as sp
>>>a, b, c = sp.symbols("a b c")
>>>ps.Assignment(sp.Matrix([a,b,c]), sp.Matrix([1,2,3]))
(Assignment(a, 1), Assignment(b, 2), Assignment(c, 3))
```
Fixes #17```python
>>>import pystencils as ps
>>>import sympy as sp
>>>a, b, c = sp.symbols("a b c")
>>>ps.Assignment(sp.Matrix([a,b,c]), sp.Matrix([1,2,3]))
(Assignment(a, 1), Assignment(b, 2), Assignment(c, 3))
```
Fixes #17https://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/129Interpolation refactoring2020-01-23T16:46:04+01:00Stephan SeitzInterpolation refactoringThis is among other small things a refactoring of the interpolation
- Make textures less special (now subclasses of interpolator)
- Remove `TextureCache`
- (Ab-) use finite differences to enable spatial derivatives of interpolators
- en...This is among other small things a refactoring of the interpolation
- Make textures less special (now subclasses of interpolator)
- Remove `TextureCache`
- (Ab-) use finite differences to enable spatial derivatives of interpolators
- enable code to use https://github.com/theHamsta/CubicInterpolationCUDA (not included into pystencils, not even as a submodule)
I can use it to transform Lenna and get gradients with Torch wrt. to image content, x-translation, y-translation
![Screenshot_20200115_182600](/uploads/32b95089b2a0d15008750db21980ed54/Screenshot_20200115_182600.png)
Also a nice image lenna
![transformed](/uploads/afb63a546751caf4a0316118afda50ef/transformed.png)https://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/135CI: Replace minimal-ubuntu job with ubuntu2020-01-23T18:35:24+01:00Michael Kuronmkuron@icp.uni-stuttgart.deCI: Replace minimal-ubuntu job with ubuntuThe case of testing that pystencils does not depend on any optional dependencies is still fulfilled by the minimal_conda image.
Depends on https://i10git.cs.fau.de/pycodegen/pycodegen/merge_requests/9.
Fixes https://i10git.cs.fau.de/...The case of testing that pystencils does not depend on any optional dependencies is still fulfilled by the minimal_conda image.
Depends on https://i10git.cs.fau.de/pycodegen/pycodegen/merge_requests/9.
Fixes https://i10git.cs.fau.de/pycodegen/pystencils/issues/19.Stephan SeitzStephan Seitzhttps://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/137Add assertion that headers follow the pattern /"..."/ or /<...>/2020-01-24T12:19:42+01:00Stephan SeitzAdd assertion that headers follow the pattern /"..."/ or /<...>/https://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/117WIP: Add InterpolatorAccess.__getnewargs__2020-01-28T14:23:15+01:00Stephan SeitzWIP: Add InterpolatorAccess.__getnewargs__it was missing and instead TypedSymbol.__getnewargs__ was usedit was missing and instead TypedSymbol.__getnewargs__ was usedhttps://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/98WIP: Graph datahandling2020-01-28T14:24:04+01:00Stephan SeitzWIP: Graph datahandlingThis is the draft for a data handling that (optionally) forwards all calls to SerialDatahandling.
All calls and data transfers get recorded for the creation of an execution graph.
Needs to be changed after the breaking changes in dat...This is the draft for a data handling that (optionally) forwards all calls to SerialDatahandling.
All calls and data transfers get recorded for the creation of an execution graph.
Needs to be changed after the breaking changes in datahandling.
Needs a tiny change in lbmpy:
Instead of using `TimeLoop(...)` for time loop creation a custom function is used.https://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/139Use `rich` for syntax highlighting of `show_code` also in terminal2020-01-30T10:18:28+01:00Stephan SeitzUse `rich` for syntax highlighting of `show_code` also in terminalStill works as usual in Jupyter notebooks and in terminal if `rich` is not installed.![Screenshot_20200130_100924](/uploads/5876a0aab841c4a2d736777cac4535f6/Screenshot_20200130_100924.png)Still works as usual in Jupyter notebooks and in terminal if `rich` is not installed.![Screenshot_20200130_100924](/uploads/5876a0aab841c4a2d736777cac4535f6/Screenshot_20200130_100924.png)https://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/127Correctly print sp.Abs in generated code2020-02-03T13:28:20+01:00Michael Kuronmkuron@icp.uni-stuttgart.deCorrectly print sp.Abs in generated codeAnother issue reported by @alexander.reinauer.Another issue reported by @alexander.reinauer.Martin BauerMartin Bauerhttps://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/141Fixed Volume of Fluid discretization and added Advection-Diffusion testcase2020-02-03T18:51:16+01:00Alexander ReinauerFixed Volume of Fluid discretization and added Advection-Diffusion testcaseFixed VoF discretization and added advection-diffusion testcase for finitevolumes and VoF discretization on behalf of @kuronFixed VoF discretization and added advection-diffusion testcase for finitevolumes and VoF discretization on behalf of @kuronMartin BauerMartin Bauerhttps://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/145Switch back to intersphinx sympy.org/latest ('coz it works)2020-02-11T19:50:44+01:00Stephan SeitzSwitch back to intersphinx sympy.org/latest ('coz it works)https://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/138Add remaining parameters from DataHandling.add_array to DataHandling.add_arrays2020-02-11T20:15:54+01:00Stephan SeitzAdd remaining parameters from DataHandling.add_array to DataHandling.add_arrayshttps://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/146FVM derivation: use a smaller stencil before trying brute-force to find the s...2020-02-12T13:24:22+01:00Michael Kuronmkuron@icp.uni-stuttgart.deFVM derivation: use a smaller stencil before trying brute-force to find the sparsest stencilD3Q7/D2Q5 should suffice for first derivatives, so try that stencil first before using brute force to find the sparsest D3Q27/D2Q9 stencil. In 2D, it does not really matter because the brute-force search is so fast, but in 3D it can take...D3Q7/D2Q5 should suffice for first derivatives, so try that stencil first before using brute force to find the sparsest D3Q27/D2Q9 stencil. In 2D, it does not really matter because the brute-force search is so fast, but in 3D it can take days to complete (due to that `itertools.product`). This pull request does not change the resulting stencil weights, it only massively speeds up the process of determining them.Martin BauerMartin Bauerhttps://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/147Added guard around import to avoid failing when walberla is there but no pyth...2020-02-21T15:15:39+01:00Christoph RettingerAdded guard around import to avoid failing when walberla is there but no python module is builtStephan SeitzStephan Seitzhttps://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/144Add TypedMatrixSymbol (for usage of `MatrixSymbol` in kernels)2020-02-21T15:16:29+01:00Stephan SeitzAdd TypedMatrixSymbol (for usage of `MatrixSymbol` in kernels)I don't know whether this is a good idea but SymPy supports assigning MatrixSymbols. Like
```python
>>>A = MatrixSymbols('A', 3, 3)
>>>B = MatrixSymbols('B', 3, 3)
In [12]: pystencils.Assignment(A, B) ...I don't know whether this is a good idea but SymPy supports assigning MatrixSymbols. Like
```python
>>>A = MatrixSymbols('A', 3, 3)
>>>B = MatrixSymbols('B', 3, 3)
In [12]: pystencils.Assignment(A, B)
Out[12]: A := B
```
With this hack I can generate code like this:
```cpp
#define FUNC_PREFIX static
2 FUNC_PREFIX void kernel(float * RESTRICT _data_y, int64_t const _size_y_0, int64_t const _size_y_1, int64_t const _size_y_2, int64_t
const _stride_y_0, int64_t const _stride_y_1, int64_t const _stride_y_2, std::function< Vector3 < double >(int, int, int) > my_fun)
3 {
4 for (int ctr_0 = 0; ctr_0 < _size_y_0; ctr_0 += 1)
5 {
6 float * RESTRICT _data_y_00 = _data_y + _stride_y_0*ctr_0;
7 for (int ctr_1 = 0; ctr_1 < _size_y_1; ctr_1 += 1)
8 {
9 float * RESTRICT _data_y_00_10 = _stride_y_1*ctr_1 + _data_y_00;
10 for (int ctr_2 = 0; ctr_2 < _size_y_2; ctr_2 += 1)
11 {
12 const Vector3<double> A = my_fun(ctr_0, ctr_1, ctr_2);
13 _data_y_00_10[_stride_y_2*ctr_2] = A[0] + A[1] + A[2];
14 }
15 }
16 }
17 }
1 #define FUNC_PREFIX static
2 template <class Functor_T>
3 FUNC_PREFIX void kernel(float * RESTRICT _data_y, int64_t const _size_y_0, int64_t const _size_y_1, int64_t const _size_y_2, int64_t
const _stride_y_0, int64_t const _stride_y_1, int64_t const _stride_y_2, Functor_T my_fun)
4 {
5 for (int ctr_0 = 0; ctr_0 < _size_y_0; ctr_0 += 1)
6 {
7 float * RESTRICT _data_y_00 = _data_y + _stride_y_0*ctr_0;
8 for (int ctr_1 = 0; ctr_1 < _size_y_1; ctr_1 += 1)
9 {
10 float * RESTRICT _data_y_00_10 = _stride_y_1*ctr_1 + _data_y_00;
11 for (int ctr_2 = 0; ctr_2 < _size_y_2; ctr_2 += 1)
12 {
13 const Vector3<double> A = my_fun(ctr_0, ctr_1, ctr_2);
14 _data_y_00_10[_stride_y_2*ctr_2] = A[0] + A[1] + A[2];
15 }
16 }
17 }
18 }
```
from
```python
x, y = pystencils.fields('x, y: float32[3d]')
from pystencils.data_types import TypedMatrixSymbol
A = TypedMatrixSymbol('A', 3, 1, create_type('double'), 'Vector3<double>')
my_fun_call = DynamicFunction(TypedSymbol('my_fun',
'std::function< Vector3 < double >(int, int, int) >'),
A.dtype,
*pystencils.x_vector(3))
assignments = pystencils.AssignmentCollection({
A: my_fun_call,
y.center: A[0] + A[1] + A[2]
})
ast = pystencils.create_kernel(assignments)
pystencils.show_code(ast, custom_backend=FrameworkIntegrationPrinter())
```https://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/143Enable overriding of kwargs in SerialDataHandling.run_kernel2020-02-22T10:41:47+01:00Stephan SeitzEnable overriding of kwargs in SerialDataHandling.run_kernel
Apparently
```python
kernel_function(**{**arrays, **kwargs})
```
does the same as
```python
call_dict = {}
call_dict.update(arrays)
call_dict.update(kwargs)
kernel_function(**call_dict)
```
Bu...
Apparently
```python
kernel_function(**{**arrays, **kwargs})
```
does the same as
```python
call_dict = {}
call_dict.update(arrays)
call_dict.update(kwargs)
kernel_function(**call_dict)
```
But
```
kernel_function(**arrays, **kwargs)
```
causes an error if a key is in arrays and kwargs.https://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/142Implement __hash__ for SympyAssignment2020-02-22T11:22:51+01:00Stephan SeitzImplement __hash__ for SympyAssignmenthttps://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/134cuda.TextureReference.set_array(tex_ref, cu_array) -> tex_ref.set_array(cu_ar...2020-02-22T11:23:26+01:00Stephan Seitzcuda.TextureReference.set_array(tex_ref, cu_array) -> tex_ref.set_array(cu_array)I missed that this is actually a member function. Better call it
directly to make it also work with `cuda.SurfaceReference`.I missed that this is actually a member function. Better call it
directly to make it also work with `cuda.SurfaceReference`.https://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/140Append assignments to KernelFunction (for later analysis etc.)2020-02-22T11:23:51+01:00Stephan SeitzAppend assignments to KernelFunction (for later analysis etc.)I wonder if it would be a good idea to apend the assignments from which a `KernelFunction` was created to `KernelFunction`.I wonder if it would be a good idea to apend the assignments from which a `KernelFunction` was created to `KernelFunction`.