Skip to content
Snippets Groups Projects
Commit 89646a2d authored by Frederik Hennig's avatar Frederik Hennig
Browse files

undid that last fix, and removed the 'target' from optimization params

parent 44fd76fa
No related merge requests found
...@@ -31,7 +31,7 @@ from pystencils_walberla import CodeGeneration, generate_pack_info_from_kernel ...@@ -31,7 +31,7 @@ from pystencils_walberla import CodeGeneration, generate_pack_info_from_kernel
from lbmpy_walberla import generate_lattice_model from lbmpy_walberla import generate_lattice_model
\endcode \endcode
First, we define a few general parameters. These include the stencil (D2Q9) and the memory layout (`fzyx`, see \ref tutorial_codegen01 ). We define a SymPy symbol for the relaxation rate \f$ \omega \f$. This means we can later set it to a specific value from the waLBerla code. A dictionary with optimization parameters is also set up. Here, we define the compilation target, enable global common subexpression elimination (`cse_global`) and set the PDF field's memory layout. In general, the target could be set to `gpu` to create a CUDA implementation, but this is currently not possible for creating a `LatticeModel` class. First, we define a few general parameters. These include the stencil (D2Q9) and the memory layout (`fzyx`, see \ref tutorial_codegen01 ). We define a SymPy symbol for the relaxation rate \f$ \omega \f$. This means we can later set it to a specific value from the waLBerla code. A dictionary with optimization parameters is also set up. Here, we enable global common subexpression elimination (`cse_global`) and set the PDF field's memory layout.
\code \code
stencil = 'D2Q9' stencil = 'D2Q9'
omega = sp.Symbol('omega') omega = sp.Symbol('omega')
......
...@@ -14,7 +14,7 @@ omega = sp.Symbol('omega') ...@@ -14,7 +14,7 @@ omega = sp.Symbol('omega')
layout = 'fzyx' layout = 'fzyx'
# Optimizations to be used by the code generator # Optimizations to be used by the code generator
optimizations = {'target': 'cpu', 'cse_global': True, 'field_layout': layout} optimizations = {'cse_global': True, 'field_layout': layout}
# =========================== # ===========================
# SRT Method Definition # SRT Method Definition
......
...@@ -9,70 +9,64 @@ from pystencils_walberla import CodeGeneration, generate_sweep, generate_pack_in ...@@ -9,70 +9,64 @@ from pystencils_walberla import CodeGeneration, generate_sweep, generate_pack_in
from lbmpy_walberla import generate_boundary from lbmpy_walberla import generate_boundary
with CodeGeneration() as ctx: # ========================
# General Parameters
# ======================== # ========================
# Target Selection
# ========================
if ctx.cuda:
target = 'gpu'
else:
target = 'cpu'
# ======================== stencil = 'D2Q9'
# General Parameters omega = sp.Symbol('omega')
# ======================== layout = 'fzyx'
stencil = 'D2Q9' # PDF Fields
omega = sp.Symbol('omega') pdfs, pdfs_tmp = ps.fields('pdfs(9), pdfs_tmp(9): [2D]', layout=layout)
layout = 'fzyx'
# PDF Fields # Velocity Output Field
pdfs, pdfs_tmp = ps.fields('pdfs(9), pdfs_tmp(9): [2D]', layout=layout) velocity = ps.fields("velocity(2): [2D]", layout=layout)
output = {'velocity': velocity}
# Velocity Output Field # Optimization
velocity = ps.fields("velocity(2): [2D]", layout=layout) optimization = {'cse_global': True,
output = {'velocity': velocity} 'symbolic_field': pdfs,
'symbolic_temporary_field': pdfs_tmp,
'field_layout': layout}
# Optimization
optimization = {'target': target,
'cse_global': True,
'symbolic_field': pdfs,
'symbolic_temporary_field': pdfs_tmp,
'field_layout': layout}
# ==================
# Method Setup
# ==================
# ================== lbm_params = {'stencil': stencil,
# Method Setup 'method': 'mrt_raw',
# ================== 'relaxation_rates': [0, 0, 0, omega, omega, omega, 1, 1, 1],
'cumulant': True,
'compressible': True}
lbm_params = {'stencil': stencil, lbm_update_rule = create_lb_update_rule(optimization=optimization,
'method': 'mrt_raw', output=output,
'relaxation_rates': [0, 0, 0, omega, omega, omega, 1, 1, 1], **lbm_params)
'cumulant': True,
'compressible': True}
lbm_update_rule = create_lb_update_rule(optimization=optimization, lbm_method = lbm_update_rule.method
output=output,
**lbm_params)
lbm_method = lbm_update_rule.method # ========================
# PDF Initialization
# ========================
# ======================== initial_rho = sp.Symbol('rho_0')
# PDF Initialization
# ========================
initial_rho = sp.Symbol('rho_0') pdfs_setter = macroscopic_values_setter(lbm_method,
initial_rho,
velocity.center_vector,
pdfs.center_vector)
pdfs_setter = macroscopic_values_setter(lbm_method, # =====================
initial_rho, # Code Generation
velocity.center_vector, # =====================
pdfs.center_vector)
# ===================== with CodeGeneration() as ctx:
# Code Generation if ctx.cuda:
# ===================== target = 'gpu'
else:
target = 'cpu'
# LBM Sweep # LBM Sweep
generate_sweep(ctx, "CumulantMRTSweep", lbm_update_rule, field_swaps=[(pdfs, pdfs_tmp)], target=target) generate_sweep(ctx, "CumulantMRTSweep", lbm_update_rule, field_swaps=[(pdfs, pdfs_tmp)], target=target)
......
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