Commit 9bad685f authored by Helen Schottenhamml's avatar Helen Schottenhamml
Browse files

Merge branch 'Fixes' into 'master'

Clean up and Bug Fixes

Closes #38

See merge request pycodegen/pystencils!264
parents a3cec2ce 6f74f2ab
Pipeline #35071 passed with stages
in 17 minutes and 57 seconds
......@@ -19,3 +19,7 @@ pystencils/boundaries/createindexlistcython.*.so
pystencils_tests/tmp
pystencils_tests/kerncraft_inputs/.2d-5pt.c_kerncraft/
pystencils_tests/kerncraft_inputs/.3d-7pt.c_kerncraft/
# macOS
**/.DS_Store
\ No newline at end of file
......@@ -14,6 +14,7 @@ tests-and-coverage:
- $ENABLE_NIGHTLY_BUILDS
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/full
script:
- pip install sympy --upgrade
- env
- pip list
- export NUM_CORES=$(nproc --all)
......@@ -94,6 +95,7 @@ minimal-windows:
- export NUM_CORES=$(nproc --all)
- source /cygdrive/c/Users/build/Miniconda3/Scripts/activate
- source activate pystencils
- pip install joblib
- pip list
- python -c "import numpy"
- py.test -v -m "not (notebook or longrun)"
......@@ -105,9 +107,9 @@ ubuntu:
- $ENABLE_NIGHTLY_BUILDS
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/ubuntu
before_script:
- apt-get -y remove python3-sympy
# - apt-get -y remove python3-sympy
- ln -s /usr/include/locale.h /usr/include/xlocale.h
- pip3 install `grep -Eo 'sympy[>=]+[0-9\.]+' setup.py | sed 's/>/=/g'`
# - pip3 install `grep -Eo 'sympy[>=]+[0-9\.]+' setup.py | sed 's/>/=/g'`
script:
- export NUM_CORES=$(nproc --all)
- mkdir -p ~/.config/matplotlib
......@@ -293,7 +295,7 @@ flake8-lint:
build-documentation:
stage: test
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/full
image: i10git.cs.fau.de:5005/pycodegen/pycodegen/documentation
script:
- export PYTHONPATH=`pwd`
- mkdir html_doc
......
%% Cell type:code id: tags:
``` python
import psutil
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import pyplot, cm
from pystencils.session import *
from pystencils.boundaries import add_neumann_boundary, Neumann, Dirichlet, BoundaryHandling
from pystencils.slicing import slice_from_direction
import math
import time
%matplotlib inline
```
%% Cell type:markdown id: tags:
Test to see if pycuda is installed which is needed to run calculations on the GPU
%% Cell type:code id: tags:
``` python
try:
import pycuda
gpu = True
except ImportError:
gpu = False
pycuda = None
print('No pycuda installed')
if pycuda:
import pycuda.gpuarray as gpuarray
```
%%%% Output: stream
No pycuda installed
%% Cell type:markdown id: tags:
# Tutorial 03: Datahandling
%% Cell type:markdown id: tags:
This is a tutorial about the `DataHandling` class of pystencils. This class is an abstraction layer to
- link numpy arrays to pystencils fields
- handle CPU-GPU array transfer, such that one can write code that works on CPU and GPU
- makes it possible to write MPI parallel simulations to run on distributed-memory clusters using the waLBerla library
We will look at a small and easy example to demonstrate the usage of `DataHandling` objects. We will define an averaging kernel to every cell of an array, that writes the average of the neighbor cell values to the center.
%% Cell type:markdown id: tags:
## 1. Manual
### 1.1. CPU kernels
In this first part, we set up a scenario manually without a `DataHandling`. In the next sections we then repeat the same setup with the help of the data handling.
One concept of *pystencils* that may be confusing at first, is the differences between pystencils fields and numpy arrays. Fields are used to describe the computation *symbolically* with sympy, while numpy arrays hold the actual values where the computation is executed on.
One option to create and execute a *pystencils* kernel is listed below. For reasons that become clear later we call this the **variable-field-size workflow**:
1. define pystencils fields
2. use sympy and the pystencils fields to define an update rule, that describes what should be done on *every cell*
3. compile the update rule to a real function, that can be called from Python. For each field that was referenced in the symbolic description the function expects a numpy array, passed as named parameter
4. create some numpy arrays with actual data
5. call the kernel - usually many times
Now, lets see how this actually looks in Python code:
%% Cell type:code id: tags:
``` python
# 1. field definitions
src_field, dst_field = ps.fields("src, dst:[2D]")
# 2. define update rule
update_rule = [ps.Assignment(lhs=dst_field[0, 0],
rhs=(src_field[1, 0] + src_field[-1, 0] +
src_field[0, 1] + src_field[0, -1]) / 4)]
# 3. compile update rule to function
kernel_function = ps.create_kernel(update_rule).compile()
# 4. create numpy arrays and call kernel
src_arr, dst_arr = np.random.rand(30, 30), np.zeros([30, 30])
# 5. call kernel
kernel_function(src=src_arr, dst=dst_arr) # names of arguments have to match names passed to ps.fields()
```
%% Cell type:markdown id: tags:
This workflow separates the symbolic and the numeric stages very cleanly. The separation also makes it possible to stop after step 3, write the C-code to a file and call the kernel from a C program. Speaking of the C-Code - lets have a look at the generated sources:
%% Cell type:code id: tags:
``` python
ps.show_code(kernel_function.ast)
```
%%%% Output: display_data
%%%% Output: display_data
%% Cell type:markdown id: tags:
Even if it looks very ugly and low-level :) lets look at this code in a bit more detail. The code is generated in a way that it works for different array sizes. The size of the array is passed in the `_size_dst_` variables that specifiy the shape of the array for each dimension. Also, the memory layout (linearization) of the array can be different. That means the array could be stored in row-major or column-major order - if we pass in the array strides correctly the kernel does the right thing. If you're not familiar with the concept of strides check out [this stackoverflow post](https://stackoverflow.com/questions/53097952/how-to-understand-numpy-strides-for-layman) or search in the numpy documentation for strides - C vs Fortran order.
The goal of *pystencils* is to produce the fastest possible code. One technique to do this is to use all available information already on compile time and generate code that is highly adapted to the specific problem. In our case we already know the shape and strides of the arrays we want to apply the kernel to, so we can make use of this information. This idea leads to the **fixed-field-size workflow**. The main difference there is that we define the arrays first and therefore let *pystencils* know about the array shapes and strides, so that it can generate more specific code:
1. create numpy arrays that hold your data
2. define pystencils fields, this time telling pystencils already which arrays they correspond to, so that it knows about the size and strides
in the other steps nothing has changed
3. define the update rule
4. compile update rule to kernel
5. run the kernel
%% Cell type:code id: tags:
``` python
# 1. create arrays first
src_arr, dst_arr = np.random.rand(30, 30), np.zeros([30, 30])
# 2. define symbolic fields - note the additional parameter that link an array to each field
src_field, dst_field = ps.fields("src, dst:[2D]", src=src_arr, dst=dst_arr)
# 3. define update rule
update_rule = [ps.Assignment(lhs=dst_field[0, 0],
rhs=(src_field[1, 0] + src_field[-1, 0] +
src_field[0, 1] + src_field[0, -1]) / 4)]
# 4. compile it
kernel_function = ps.create_kernel(update_rule).compile()
# 5. call kernel
kernel_function(src=src_arr, dst=dst_arr) # names of arguments have to match names passed to ps.fields()
```
%% Cell type:markdown id: tags:
Functionally, both variants are equivalent. We see the difference only when we look at the generated code
%% Cell type:code id: tags:
``` python
ps.show_code(kernel_function.ast)
```
%%%% Output: display_data
%%%% Output: display_data
%% Cell type:markdown id: tags:
Compare this to the code above! It looks much simpler. The reason is that all index computations are already simplified since the exact field sizes and strides are known. This kernel now only works on arrays of the previously specified size.
Lets try what happens if we use a different array:
%% Cell type:code id: tags:
``` python
src_arr2, dst_arr2 = np.random.rand(40, 40), np.zeros([40, 40])
try:
kernel_function(src=src_arr2, dst=dst_arr2)
except ValueError as e:
print(e)
```
%%%% Output: stream
Wrong shape of array dst. Expected (30, 30)
%% Cell type:markdown id: tags:
### 1.2. GPU simulations
Let's now jump to a seemingly unrelated topic: running kernels on the GPU.
When creating the kernel, an additional parameter `target=ps.Target.GPU` has to be passed. Also, the compiled kernel cannot be called with numpy arrays directly, but has to be called with `pycuda.gpuarray`s instead. That means, we have to transfer our numpy array to GPU first. From this step we obtain a gpuarray, then we can run the kernel, hopefully multiple times so that the data transfer was worth the time. Finally we transfer the finished result back to CPU:
%% Cell type:code id: tags:
``` python
if pycuda:
config = ps.CreateKernelConfig(target=ps.Target.GPU)
kernel_function_gpu = ps.create_kernel(update_rule, config=config).compile()
# transfer to GPU
src_arr_gpu = pycuda.gpuarray.to_gpu(src_arr)
dst_arr_gpu = pycuda.gpuarray.to_gpu(dst_arr)
# run kernel on GPU, this is done many times in real setups
kernel_function_gpu(src=src_arr_gpu, dst=dst_arr_gpu)
# transfer result back to CPU
dst_arr_gpu.get(dst_arr)
```
%% Cell type:markdown id: tags:
### 1.3. Summary: manual way
- Don't confuse *pystencils* fields and *numpy* arrays
- fields are symbolic
- arrays are numeric
- Use the fixed-field-size workflow whenever possible, since code might be faster. Create arrays first, then create fields from arrays
- if we run GPU kernels, arrays have to transferred to the GPU first
As demonstrated in the examples above we have to define 2 or 3 corresponding objects for each grid:
- symbolic pystencils field
- numpy array on CPU
- for GPU run also a pycuda.gpuarray to mirror the data on the GPU
Managing these three objects manually is tedious and error-prone. We'll see in the next section how the data handling object takes care of this problem.
%% Cell type:markdown id: tags:
## 2. Introducing the data handling - serial version
### 2.1. Example for CPU simulations
The data handling internally keeps a mapping between symbolic fields and numpy arrays. When we create a field, automatically a corresponding array is allocated as well. Optionally we can also allocate memory on the GPU for the array as well. Lets dive right in and see how our example looks like, when implemented with a data handling.
%% Cell type:code id: tags:
``` python
dh = ps.create_data_handling(domain_size=(30, 30))
# fields are now created using the data handling
src_field = dh.add_array('src', values_per_cell=1)
dst_field = dh.add_array('dst', values_per_cell=1)
# kernel is created just like before
update_rule = [ps.Assignment(lhs=dst_field[0, 0],
rhs=(src_field[1, 0] + src_field[-1, 0] + src_field[0, 1] + src_field[0, -1]) / 4)]
kernel_function = ps.create_kernel(update_rule).compile()
# have a look at the generated code - it uses
# the fast version where array sizes are compiled-in
# ps.show_code(kernel_function.ast)
```
%% Cell type:markdown id: tags:
The data handling has methods to create fields - but where are the corresponding arrays?
In the serial case you can access them as a member of the data handling, for example to initialize our 'src' array we can write
%% Cell type:code id: tags:
``` python
src_arr = dh.cpu_arrays['src']
src_arr.fill(0.0)
```
%% Cell type:markdown id: tags:
This method is nice and easy, but you should not use it if you want your simulation to run on distributed-memory clusters. We'll see why in the last section. So it is good habit to not access the arrays directly but use the data handling to do so. We can, for example, initialize the array also with the following code:
%% Cell type:code id: tags:
``` python
dh.fill('src', 0.0)
```
%% Cell type:markdown id: tags:
To run the kernels with the same code as before, we would also need the arrays. We could do that accessing the `cpu_arrays`:
%% Cell type:code id: tags:
``` python
kernel_function(src=dh.cpu_arrays['src'],
dst=dh.cpu_arrays['dst'])
```
%% Cell type:markdown id: tags:
but to be prepared for MPI parallel simulations, again a method of the data handling should be used for this.
Besides, this method is also simpler to use - since it automatically detects which arrays a kernel uses and passes them in.
%% Cell type:code id: tags:
``` python
dh.run_kernel(kernel_function)
```
%% Cell type:markdown id: tags:
To access the data read-only instead of using `cpu_arrays` the gather function should be used.
This function gives you a read-only copy of the domain or part of the domain.
We will discuss this function later in more detail when we look at MPI parallel simulations.
For serial simulations keep in mind that modifying the resulting array does not change your original data!
%% Cell type:code id: tags:
``` python
read_only_copy = dh.gather_array('src', ps.make_slice[:, :], ghost_layers=False)
```
%% Cell type:markdown id: tags:
### 2.2. Example for GPU simulations
In this section we have a look at GPU simulations using the data handling. Only minimal changes are required.
When creating the data handling we can pass a 'default_target'. This means for every added field an array on the CPU and the GPU is allocated. This is a useful default, for more fine-grained control the `add_array` method also takes additional parameters controlling where the array should be allocated.
Additionally we also need to compile a GPU version of the kernel.
%% Cell type:code id: tags:
``` python
dh = ps.create_data_handling(domain_size=(30, 30), default_target=ps.Target.GPU)
if gpu is False:
dh = ps.create_data_handling(domain_size=(30, 30), default_target=ps.Target.CPU)
else:
dh = ps.create_data_handling(domain_size=(30, 30), default_target=ps.Target.GPU)
# fields are now created using the data handling
src_field = dh.add_array('src', values_per_cell=1)
dst_field = dh.add_array('dst', values_per_cell=1)
# kernel is created just like before
update_rule = [ps.Assignment(lhs=dst_field[0, 0],
rhs=(src_field[1, 0] + src_field[-1, 0] + src_field[0, 1] + src_field[0, -1]) / 4)]
config = ps.CreateKernelConfig(target=dh.default_target)
kernel_function = ps.create_kernel(update_rule, config=config).compile()
dh.fill('src', 0.0)
```
%% Cell type:markdown id: tags:
The data handling provides function to transfer data between CPU and GPU
%% Cell type:code id: tags:
``` python
dh.to_gpu('src')
if gpu:
dh.to_gpu('src')
dh.run_kernel(kernel_function)
dh.to_cpu('dst')
if gpu:
dh.to_cpu('dst')
```
%% Cell type:markdown id: tags:
usually one wants to transfer all fields that have been allocated on CPU and GPU at the same time:
%% Cell type:code id: tags:
``` python
dh.all_to_gpu()
dh.run_kernel(kernel_function)
dh.all_to_cpu()
```
%% Cell type:markdown id: tags:
We can always include the `all_to_*` functions in our code, since they do nothing if there are no arrays allocated on the GPU. Thus there is only a single point in the code where we can switch between CPU and GPU version: the `default_target` of the data handling.
%% Cell type:markdown id: tags:
### 2.2 Ghost Layers and periodicity
The data handling can also provide periodic boundary conditions. Therefor the domain is extended by one layer of cells, the so-called ghost layer or halo layer.
%% Cell type:code id: tags:
``` python
print("Shape of domain ", dh.shape)
print("Direct access to arrays ", dh.cpu_arrays['src'].shape)
print("Gather ", dh.gather_array('src', ghost_layers=True).shape)
```
%%%% Output: stream
Shape of domain (30, 30)
Direct access to arrays (32, 32)
Gather (32, 32)
%% Cell type:markdown id: tags:
So the actual arrays are 2 cells larger than what you asked for. This additional layer is used to copy over the data from the other end of the array, such that for the stencil algorithm effectively the domain is periodic. This copying operation has to be started manually though:
%% Cell type:code id: tags:
``` python
dh = ps.create_data_handling((4, 4), periodicity=(True, False))
dh.add_array("src")
# get copy function
copy_fct = dh.synchronization_function(['src'])
dh.fill('src', 0.0, ghost_layers=True)
dh.fill('src', 3.0, ghost_layers=False)
before_sync = dh.gather_array('src', ghost_layers=True).copy()
copy_fct() # copy over to get periodicity in x direction
after_sync = dh.gather_array('src', ghost_layers=True).copy()
plt.subplot(1,2,1)
plt.scalar_field(before_sync);
plt.title("Before")
plt.subplot(1,2,2)
plt.scalar_field(after_sync);
plt.title("After");
```
%%%% Output: display_data
![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA5gAAAF1CAYAAACNjUXIAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAV7ElEQVR4nO3dfbCmB1nf8d9lNrwItLRyoJAACwpodJpgtwhCnTEtEAWBdgYEK9IZp6kddbDDDOo/nfoHTjvtINpaS0QIo7yU8tJBoEAoIKXytguBEgIamUAShCzSCFgLTbj6x3kyLmFfnt29nn1e8vnMnNlzzt7n2euezeba7z73c5/q7gAAAMDZ+rZ1DwAAAMBuEJgAAACMEJgAAACMEJgAAACMEJgAA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rJzUmu6u4PrHQqAOCk7GYANtFSgdndt3X3JUkuTPKoqvq+Ox5TVZdX1eGqOnz06NHhMQGAY9nNAGyi07qLbHffkuRdSS47zs9d0d2HuvvQ3t7e0HgAwMnYzQBskmXuIrtXVfdevH/3JI9P8skVzwUAnIDdDMCmWuYusvdP8vKqOi/7Qfqa7n7TascCAE7CbgZgIy1zF9mPJXnkOZgFAFiC3QzApjqt12ACAADAiQhMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARpwyMKvqgVX1rqr6RFVdU1XPPReDAQDHZzcDsKkOLHHMrUme190frqp7JTlSVVd19ydWPBsAcHx2MwAb6ZTPYHb3n3b3hxfvfyXJtUkuWPVgAMDx2c0AbKrTeg1mVR1M8sgkH1jJNADAabGbAdgkSwdmVd0zyeuS/EJ3f/k4P395VR2uqsNHjx6dnBEAOA67GYBNs1RgVtX52V9gr+ju1x/vmO6+orsPdfehvb29yRkBgDuwmwHYRMvcRbaS/E6Sa7v7hasfCQA4GbsZgE21zDOYj03y7CSXVtXVi7cfXfFcAMCJ2c0AbKRTfpuS7n5vkjoHswAAS7CbAdhUp3UXWQAAADgRgQkAAMAIgQkAAMAIgQkAAMAIgQkAAMAIgQkAAMAIgQkAAMAIgQkAAMAIgQkAAMAIgQkAAMAIgQkAAMAIgQkAAMAIgQkAAMAIgQkAAMAIgQkAAMAIgQkAAMAIgQkAAMAIgQkAAMAIgQkAAMAIgQkAAMAIgQkAAMAIgQkAAMAIgQkAAMAIgQkAAMAIgQkAAMAIgQkAAMAIgQkAAMAIg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bhEFs7C4u6uz0ryV7J/N7rfSvKrVfXAxc9fUFVPO8GXvyPJo6rqx6rqwOKmAhcledsJjn/b4vjnV9X5i7e/XVWPmT0rANh6z87+txO7KPtXGF2S5DFJ/mv2X5d5V1/I/o1/7vRbSX66qr53sevvU1VPr6r7rXJo2AUCE87M71XVV7P/GsyXJHlBd1+X5BeS3JDkQ1X15STvSfLo4z1Ad/95kmckeVGSP0/y4iTPOOZSnrse/5UkT83+azpvSfL57N9U6J7HOx4A7sZekORV3f257v78nW9JfiPJP8q3XsX3L5K8enHH2Od09+Hsvw7zN5L8z+zv9n98zqaHLVbdnt0HAADg7HkGEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBF3vUXziAc84AF98ODBVTz0WfvjI59Z9wgAG+dRf+sRpz5oTY4cOfLF7t5b9xzbzm4G2C7buptXEpgHDx7M4cOHV/HQZ+0p3/Yj6x4BYONcffg/rnuEE6qqz657hl1gNwNsl23dzS6RBQAAYITABAAAYITABAAAYITABAAAYITABAAAYITABAAAYITABAAAYITABAAAYITABAAAYITABAAAYITABAAAYITABAAAYITABAAAYITABAAAYITABAAAYITABAAAYITABAAAYITABAAAYITABAAAYITABAAAYITABAAAYMSBZQ6qqhuTfCXJHUlu7+5DqxwKADg5uxmATbRUYC78QHd/cWWTAACny24GYKO4RBYAAIARywZmJ3l3VR2pqitWORAAsBS7GYCNs+wlspd29y1V9cAkV1fVp7r7/ccesFhuVyTJwx72sOExAYC7sJsB2DhLPYPZ3bcsfrw1yVuSPOE4x1zZ3Ye6+9De3t7slADAN7GbAdhEpwzMqrpPVd3vzveTPDXJJ1c9GABwfHYzAJtqmUtkH5TkLVV15/Gv7e53rnQqAOBk7GYANtIpA7O7P5Pk4nMwCwCwBLsZgE3l25QAAAAwQmACAAAwQmACAAAwQmACAAAwQmACAAAwQmACAAAwQmACAAAwQmACAAAwQmACAAAwQmACAAAwQmACAAAwQmACAAAwQmACAAAwQmACAAAwQmACAAAwQmACAAAwQmACAAAwQmACAAAwQmACAAAwQmACAAAwQmACAAAwQmACAAAw4sC6B2DGu265dt0jwM572kMuWfcIsJPsMIDd4RlMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARiwdmFV1XlX9YVW9bZUDAQDLsZsB2DSn8wzmC5Ncv6pBAIDTZjcDsFGWCsyqujDJ05O8YrXjAADLsJsB2ETLPoP5siQvTvKNEx1QVVdU1eGqOnz06NGJ2QCAE3tZ7GYANswpA7OqnpHk1u4+crLjuvvK7j7U3Yf29vbGBgQAvpndDMCmWuYZzEuTPLOqbkzy+iSXVdXvrnQqAOBk7GYANtIpA7O7f6m7L+zug0mem+S93f3jK58MADguuxmATeX7YAIAADDiwOkc3N3XJLlmJZMAAKfNbgZgk3gGEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBECEwAAgBGnDMyquldVfaSqPl5V11XVL5+LwQCA47ObAdhUB5Y45mtJLuvur1bV+Uk+UFX/ubs/tOLZAIDjs5sB2EinDMzu7iRfXXx4/uKtVzkUAHBidjMAm2qp12BW1XlVdW2SW5Nc3d0fXulUAMBJ2c0AbKKlArO77+juS5JcmOQJVfU9dz2mqq6oqsNVdfjo0aPDYwIAx7KbAdhEp3UX2e6+Lck1SS4/zs9d2d2HuvvQ3t7ezHQAwEnZzQBskmXuIrtXVfdfvH/vJE9O8qkVzwUAnIDdDMCmWuYusg9O8uqqOi/7QfqG7n7bascCAE7CbgZgIy1zF9lPJHncOZgFAFiC3QzApjqt12ACAADAiQhMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARghMAAAARpwyMKvqoVX1vqq6vqquq6oXnovBAIDjs5sB2FQHljjm9iQv6u6PVdX9khypqqu7+49WPBsAcHx2MwAb6ZTPYHb3n3X3xxbvfyXJ9UkuWPVgAMDx2c0AbKrTeg1mVR1M8rgkH17JNADAabGbAdgkSwdmVd03yZuS/Hx3f/k4P39FVR2uqsNHjx6dnBEAOA67GYBNs1RgVtX52V9gr+nuNx/vmO6+srsPdfehvb29yRkBgLuwmwHYRMvcRbaS/HaS67v7pasfCQA4GbsZgE21zDOYlyZ5fpLLquraxdsPrXguAODE7GYANtIpv01Jd38gSZ2DWQCAJdjNAGyq07qLLAAAAJyIwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQAAGCEwAQA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8fGGSW9Y0C0uqqvOzv8Be091vXvc807r7tqq6Jvuv09n2G0FcmuSZVfVDSe6V5Duq6ne7+8fXPNeI7r5l8eOtVfWW7F/at+2vgbs5yc3H/Cv9GyMwN4LdzCazm7eK3bx9VrKbXSK7Gh9N8siq+q6qukeS5yZ565pn4iSqqrJ//fn13f3Sdc8zpar2qur+i/fvneTJST611qEGdPcvdfeF3X0w+3++3rsrC6yq7lNV97vz/SRPzfb/pSPd/fkkN1XVoxef+ntJ/miNI3H3YzdvGbt5u9jN22dVu3ljArOq/n5V3ZzkSUneXlXvWvdMZ6q7b0/ys0nelf0XpL+hu69b71Qzqup1ST6Y5NFVdXNV/eS6ZxpyaZLnJ7lscfvpaxf/ArftHpzkfVX1iez/5erq7t6p24bvoAcl+UBVfTzJR5K8vbvfueaZpvxcktcs/nu8JMmvrHccTsVu3g5289axm7eP3XwaqtvLDwAAADh7G/MMJgAAANtNYAIAADBCYAIAADBCYAIAADBCYAIAADBCYAIAADBCYAIAADBCYAIAADDi/wF+T0bWvr8CzQAAAABJRU5ErkJggg==)
%% Cell type:markdown id: tags:
## 3. Going (MPI) parallel - the parallel data handling
### 3.1. Conceptual overview
To run MPI parallel simulations the waLBerla framework is used. waLBerla has to be compiled against your local MPI library and thus is a bit hard to install. We suggest to use the version shipped with conda for testing. For production, when you want to run on a cluster the best option is to build waLBerla yourself against the MPI library that is installed on your cluster.
Now lets have a look on how to write code that runs MPI parallel.
Since the data is distributed, we don't have access to the full array any more but only to the part that is stored locally. The domain is split into so called blocks, where one process might get one (or sometimes multiple) blocks. To do anything with the local part of the data we iterate over the **local** blocks to get the contents as numpy arrays. The blocks returned in the loop differ from process to process.
Copy the following snippet to a python file and run with multiple processes e.g.:
``mpirun -np 4 myscript.py`` you will see that there are as many blocks as processes.
%% Cell type:code id: tags:
``` python
dh = ps.create_data_handling(domain_size=(30, 30), parallel=True)
field = dh.add_array('field')
for block in dh.iterate():
# offset is in global coordinates, where first inner cell has coordiante (0,0)
# and ghost layers have negative coordinates
print(block.offset, block['field'].shape)
# use offset to create a local array 'my_data' for the part of the domain
#np.copyto(block[field.name], my_data)
```
%%%% Output: error
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-20-779cf1a58f81> in <module>
/var/folders/07/0d7kq8fd0sx24cs53zz90_qc0000gp/T/ipykernel_12833/1198112608.py in <module>
----> 1 dh = ps.create_data_handling(domain_size=(30, 30), parallel=True)
2 field = dh.add_array('field')
3 for block in dh.iterate():
4 # offset is in global coordinates, where first inner cell has coordiante (0,0)
5 # and ghost layers have negative coordinates
~/git/pystencils/pystencils/datahandling/__init__.py in create_data_handling(domain_size, periodicity, default_layout, default_target, parallel, default_ghost_layers, opencl_queue)
38 assert not opencl_queue, "OpenCL is only supported for SerialDataHandling"
39 if wlb is None:
---> 40 raise ValueError("Cannot create parallel data handling because walberla module is not available")
41
42 if periodicity is False or periodicity is None:
~/pystencils/pystencils/pystencils/datahandling/__init__.py in create_data_handling(domain_size, periodicity, default_layout, default_target, parallel, default_ghost_layers, opencl_queue)
46 assert not opencl_queue, "OpenCL is only supported for SerialDataHandling"
47 if wlb is None:
---> 48 raise ValueError("Cannot create parallel data handling because walberla module is not available")
49
50 if periodicity is False or periodicity is None:
ValueError: Cannot create parallel data handling because walberla module is not available
%% Cell type:markdown id: tags:
To get some more interesting results here in the notebook we put multiple blocks onto our single notebook process. This makes not much sense for real simulations, but for testing and demonstration purposes this is useful.
%% Cell type:code id: tags:
``` python
from waLBerla import createUniformBlockGrid
from pystencils.datahandling import ParallelDataHandling
blocks = createUniformBlockGrid(blocks=(2,1,2), cellsPerBlock=(20, 10, 20),
oneBlockPerProcess=False, periodic=(1, 0, 0))
dh = ParallelDataHandling(blocks)
field = dh.add_array('field')
for block in dh.iterate():
print(block.offset, block['field'].shape)
```
%% Cell type:markdown id: tags:
Now we see that we have four blocks with (20, 10, 20) block each, and the global domain is (40, 10, 40) big.
All subblock also have a ghost layer around them, which is used to synchronize with their neighboring blocks (over the network). For ghost layer synchronization the same `synchronization_function` is used that we used above for periodic boundaries, because copying between blocks and copying the ghost layer for periodicity uses the same mechanism.
%% Cell type:code id: tags:
``` python
dh.gather_array('field').shape
```
%% Cell type:markdown id: tags:
### 3.2. Parallel example
To illustrate this in more detail, lets run a simple kernel on a parallel domain. waLBerla can handle 3D domains only, so we choose a z-size of 1.
%% Cell type:code id: tags:
``` python
blocks = createUniformBlockGrid(blocks=(2,4,1), cellsPerBlock=(20, 10, 1),
oneBlockPerProcess=False, periodic=(1, 1, 0))
dh = ParallelDataHandling(blocks, dim=2)
src_field = dh.add_array('src')
dst_field = dh.add_array('dst')
update_rule = [ps.Assignment(lhs=dst_field[0, 0 ],
rhs=(src_field[1, 0] + src_field[-1, 0] +
src_field[0, 1] + src_field[0, -1]) / 4)]
# 3. compile update rule to function
kernel_function = ps.create_kernel(update_rule).compile()
```
%% Cell type:markdown id: tags:
Now lets initialize the arrays. To do this we can get arrays (meshgrids) from the block with the coordinates of the local cells. We use this to initialize a circular shape.
%% Cell type:code id: tags:
``` python
dh.fill('src', 0.0)
for block in dh.iterate(ghost_layers=False, inner_ghost_layers=False):
x, y = block.midpoint_arrays
inside_sphere = (x -20)**2 + (y-25)**2 < 8 ** 2
block['src'][inside_sphere] = 1.0
plt.scalar_field( dh.gather_array('src') );
```
%% Cell type:markdown id: tags:
Now we can run our compute kernel on this data as usual. We just have to make sure that the field is synchronized after every step, i.e. that the ghost layers are correctly updated.
%% Cell type:code id: tags:
``` python
sync = dh.synchronization_function(['src'])
for i in range(40):
sync()
dh.run_kernel(kernel_function)
dh.swap('src', 'dst')
```
%% Cell type:code id: tags:
``` python
plt.scalar_field( dh.gather_array('src') );
```
......