pystencils merge requestshttps://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests2020-01-14T15:46:47+01:00https://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/93Reimplement create_staggered_kernel2020-01-14T15:46:47+01:00Michael Kuronmkuron@icp.uni-stuttgart.deReimplement create_staggered_kernel`create_staggered_kernel` now takes a list of assignments to staggered fields and otherwise behaves like `create_kernel`. I have included a diffusion equation test case in both D2Q5 and D2Q9. Putting vectorial/tensorial quantities on the...`create_staggered_kernel` now takes a list of assignments to staggered fields and otherwise behaves like `create_kernel`. I have included a diffusion equation test case in both D2Q5 and D2Q9. Putting vectorial/tensorial quantities on the staggered points also works.
This merge requests break API compatibility with the previous `create_staggered_kernel`.
Fixes #16. My next step is to implement automatic FV discretization.
Build of dependent projects (pygrandchem, pystencils_walberla) passes as per https://i10git.cs.fau.de/pycodegen/pycodegen/merge_requests/6.
Martin BauerMartin Bauerhttps://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/92More staggered grid improvements2019-12-17T14:52:00+01:00Michael Kuronmkuron@icp.uni-stuttgart.deMore staggered grid improvements- Fix access to directions with mixed signs (`NW`, `(-1/2, 1/2)` and the like). They were previously mapped to the wrong cell.
- When storing fluxes on a staggered grid, the usual sign convention is that
fluxes point outward from the c...- Fix access to directions with mixed signs (`NW`, `(-1/2, 1/2)` and the like). They were previously mapped to the wrong cell.
- When storing fluxes on a staggered grid, the usual sign convention is that
fluxes point outward from the cell. Previously, we did not consistently respect that
(`staggered_access("E")` would return the same thing as `staggered_access("W")`
did when called from the eastern-next cell). Now, when a field is declared
as `STAGGERED_FLUX`, it returns an accessor with a prefactor of -1 in that
case. The previous behavior where sign is not reversed is still useful when
e.g. storing sums (e.g. mean values) instead of differenes (e.g. finite
difference fluxes) on the staggered grid.
- `staggered_vector_access` returns a vector/tensor full of `Access` objects corresponding to the shape (`index_shape[1:]`) of the staggered fieldMartin BauerMartin Bauerhttps://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/91Avoid `hash()` in Field.hashable_contents2019-11-21T20:27:55+01:00Stephan SeitzAvoid `hash()` in Field.hashable_contentshash should not be used in hashable_contents because even if we will use
a deterministic hash function we will end up non-deterministic since
hash is initialized with a random seed.hash should not be used in hashable_contents because even if we will use
a deterministic hash function we will end up non-deterministic since
hash is initialized with a random seed.https://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/90Change `Field.__repr__` to match representation in `pystencils.fields`2019-11-21T20:28:32+01:00Stephan SeitzChange `Field.__repr__` to match representation in `pystencils.fields`__repr__ of Field should look like
```
y: uint16_t[246,704,558]
x(3): float[20,40]
```
to match representation when using `pystencils.fields`
E.g.
```
In [3]: pystencils.fields('x: float32[20,40]') ...__repr__ of Field should look like
```
y: uint16_t[246,704,558]
x(3): float[20,40]
```
to match representation when using `pystencils.fields`
E.g.
```
In [3]: pystencils.fields('x: float32[20,40]')
Out[3]: x: float[20,40])
In [4]: pystencils.fields('x(3): float32[20,40]')
Out[4]: x(3): float[20,40])
```https://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/89cbackend: short-cut _print_Conditional if condition is a boolean atom2019-11-21T20:06:33+01:00Michael Kuronmkuron@icp.uni-stuttgart.decbackend: short-cut _print_Conditional if condition is a boolean atomWithout this merge request, it prints
```c++
if(True)
{
[...]
}
else
{
[...]
}
```
Note the uppercase `T`, which is not valid C++.Without this merge request, it prints
```c++
if(True)
{
[...]
}
else
{
[...]
}
```
Note the uppercase `T`, which is not valid C++.Martin BauerMartin Bauerhttps://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/88fix minor regressions introduced with !862019-11-21T20:05:55+01:00Michael Kuronmkuron@icp.uni-stuttgart.defix minor regressions introduced with !86- `DataHandling.array_like` did not preserve staggeredness.
- Printing a staggered `FieldAccess` sometimes threw errors because of `int` vs. `numpy.int64`.
- Accessing an invalid staggered neighbor did not produce a good error message....- `DataHandling.array_like` did not preserve staggeredness.
- Printing a staggered `FieldAccess` sometimes threw errors because of `int` vs. `numpy.int64`.
- Accessing an invalid staggered neighbor did not produce a good error message.
- I had reversed the index convention so that it was inconsistent with the documentation of `create_staggered_kernel`.Martin BauerMartin Bauerhttps://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/87OpenCL macOS support2019-12-03T13:38:45+01:00Michael Kuronmkuron@icp.uni-stuttgart.deOpenCL macOS supportEither my laptop's GPU (Intel Iris Graphics 550) or Apple's OpenCL implementation does not support double precision. This patch checks all kernel arguments for double precision types, though I guess there is probably some easier way to j...Either my laptop's GPU (Intel Iris Graphics 550) or Apple's OpenCL implementation does not support double precision. This patch checks all kernel arguments for double precision types, though I guess there is probably some easier way to just check the entire AST, but I couldn't figure out how.
Also, `get_local_id` et al. return `size_t` per the OpenCL specification, while CUDA's `threadIdx` et al. return an `int`, so there is a cast needed to silence a conversion warning.Stephan SeitzStephan Seitzhttps://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/86Staggered field access and staggered fields with fluxes to edges/faces2019-12-17T14:52:00+01:00Michael Kuronmkuron@icp.uni-stuttgart.deStaggered field access and staggered fields with fluxes to edges/facesThe first index dimension is always used to identify the staggered point, any further ones can be used to store vectors/tensors at these points. `f.staggered_access("N")` or `f.staggered_access(0, sp.Rational(1, 2)))` is now supported. T...The first index dimension is always used to identify the staggered point, any further ones can be used to store vectors/tensors at these points. `f.staggered_access("N")` or `f.staggered_access(0, sp.Rational(1, 2)))` is now supported. The string representation of the resulting accessor is $`f_{(0,\frac{1}{2})}`$. Furthermore, staggered fields can now have more staggered points than spatial dimensions, i.e. to store fluxes to edge/face neighbors (e.g. `f.staggered_access("NE")`.Martin BauerMartin Bauerhttps://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/84Remove duplicated uint typedef2019-11-06T12:41:39+01:00Michael Kuronmkuron@icp.uni-stuttgart.deRemove duplicated uint typedefRunning the OpenCL test on AMD's ROCm platform results in
```
pystencils_tests/test_opencl.py::test_without_cuda
/usr/lib/python3/dist-packages/pyopencl/cffi_cl.py:1516: CompilerWarning: Built kernel retrieved from cache. Original from...Running the OpenCL test on AMD's ROCm platform results in
```
pystencils_tests/test_opencl.py::test_without_cuda
/usr/lib/python3/dist-packages/pyopencl/cffi_cl.py:1516: CompilerWarning: Built kernel retrieved from cache. Original from-source build had warnings:
Build on <pyopencl.Device 'gfx900' on 'AMD Accelerated Parallel Processing' at 0x34f0f50> succeeded, but said:
In file included from /tmp/comgr-1f94f8/input/CompileCLSource:1:
./pystencils/pystencils/include/opencl_stdint.h:4:27: warning: redefinition of typedef 'uint' is a C11 feature
typedef unsigned int uint;
^
/data/jenkins_workspace/compute-rocm-rel-2.9/out/ubuntu-16.04/16.04/srctf/ocl_lc/drivers/opencl/library/amdgcn/headers/build/lnx64a/B_rel/<stdin>:52:22: note: previous definition is here
typedef unsigned int uint;
```
According to the [specification](https://www.khronos.org/registry/OpenCL/specs/2.2/html/OpenCL_C.html#built-in-scalar-data-types), the `uint` type is part of the OpenCL C builtin types (and has been since version 1.0), so this typedef is not needed. In Nvidia's OpenCL stack, it appears to be built into the compiler, while LLVM (and thus AMD) define it in a [header file](https://github.com/llvm/llvm-project/blob/89de0d8dfbb9a6ff1f8b141ed70b563ecc094878/clang/lib/Headers/opencl-c.h#L55).Stephan SeitzStephan Seitzhttps://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/83Fix create_cuda_kernel to allow CUSTOM_FIELDS to have a different size2019-11-12T13:49:38+01:00Stephan SeitzFix create_cuda_kernel to allow CUSTOM_FIELDS to have a different sizeThe CPU backend allows Fields with FieldType.CUSTOM to have a differnt spatial_shape. The GPU backend should also.The CPU backend allows Fields with FieldType.CUSTOM to have a differnt spatial_shape. The GPU backend should also.https://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/82Add Field.itemsize (yields Field.dtype.numpy_dtype.itemsize)2019-10-29T10:31:47+01:00Stephan SeitzAdd Field.itemsize (yields Field.dtype.numpy_dtype.itemsize)https://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/81Oops, forgot a return in TextureCachedField.reproducible_hash2019-10-28T13:26:22+01:00Stephan SeitzOops, forgot a return in TextureCachedField.reproducible_hashhttps://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/80Use reproducible hashlib for representing TextureCachedField2019-10-28T12:38:04+01:00Stephan SeitzUse reproducible hashlib for representing TextureCachedFieldTextureCachedField was using `hash(...)` to disambiguate its instances.
However, `hash` is randomized and will hinder reproducible code
generationTextureCachedField was using `hash(...)` to disambiguate its instances.
However, `hash` is randomized and will hinder reproducible code
generationhttps://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/79Add sympy to known_third_party in .isort.cfg2019-10-28T11:33:12+01:00Stephan SeitzAdd sympy to known_third_party in .isort.cfgI have installed the newest master of SymPy as editable package.
So `isort` thinks it's one of our libraries.
With this config SymPy is declared as a third party dependency.I have installed the newest master of SymPy as editable package.
So `isort` thinks it's one of our libraries.
With this config SymPy is declared as a third party dependency.https://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/78correctly print RNG nodes2019-10-21T14:05:18+02:00Michael Kuronmkuron@icp.uni-stuttgart.decorrectly print RNG nodesRegular assignments also use `\\leftarrow`. `<-` looks odd in Jupyter because it renders like `< -PhiloxRNG`, where it looks like less than minus.Regular assignments also use `\\leftarrow`. `<-` looks odd in Jupyter because it renders like `< -PhiloxRNG`, where it looks like less than minus.Martin BauerMartin Bauerhttps://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/77Run opencl without pycuda2019-10-21T14:06:35+02:00Stephan SeitzRun opencl without pycudaFix #15
This includes !76.
If anyone wants to use textures on OpenCL, we need to decouple `TextureInterpolatedField` from CUDA.Fix #15
This includes !76.
If anyone wants to use textures on OpenCL, we need to decouple `TextureInterpolatedField` from CUDA.https://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/76Fix OpenCL with older Sympy and pyopencl versions2019-10-21T14:06:35+02:00Michael Kuronmkuron@icp.uni-stuttgart.deFix OpenCL with older Sympy and pyopencl versionsI'm using sympy and pyopencl from the Ubuntu 18.04 repositories and these changes were required to make the OpenCL tests pass on an Nvidia machine. AMD doesn't work, see #15.I'm using sympy and pyopencl from the Ubuntu 18.04 repositories and these changes were required to make the OpenCL tests pass on an Nvidia machine. AMD doesn't work, see #15.Stephan SeitzStephan Seitzhttps://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/75Add option to omit globals when printing C code2019-10-21T14:06:59+02:00Stephan SeitzAdd option to omit globals when printing C codeRight know, needed globals are always printed. But this is not always desired, e.g. when printing multiple functions and all globals should be on top of file.Right know, needed globals are always printed. But this is not always desired, e.g. when printing multiple functions and all globals should be on top of file.https://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/74Add __str__ representation for TextureDeclaration2019-10-21T14:07:20+02:00Stephan SeitzAdd __str__ representation for TextureDeclarationhttps://i10git.cs.fau.de/pycodegen/pystencils/-/merge_requests/73Bugfix: textures should be implemented as textures without changes2019-10-21T14:07:44+02:00Stephan SeitzBugfix: textures should be implemented as textures without changesFixes a small bug when using textures directly. Textures where different despite having the same hash.Fixes a small bug when using textures directly. Textures where different despite having the same hash.