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
Branches
Tags
No related merge requests found
......@@ -31,7 +31,7 @@ from pystencils_walberla import CodeGeneration, generate_pack_info_from_kernel
from lbmpy_walberla import generate_lattice_model
\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
stencil = 'D2Q9'
omega = sp.Symbol('omega')
......
......@@ -14,7 +14,7 @@ omega = sp.Symbol('omega')
layout = 'fzyx'
# 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
......
......@@ -9,70 +9,64 @@ from pystencils_walberla import CodeGeneration, generate_sweep, generate_pack_in
from lbmpy_walberla import generate_boundary
with CodeGeneration() as ctx:
# ========================
# Target Selection
# ========================
if ctx.cuda:
target = 'gpu'
else:
target = 'cpu'
# ========================
# General Parameters
# ========================
# ========================
# General Parameters
# ========================
stencil = 'D2Q9'
omega = sp.Symbol('omega')
layout = 'fzyx'
stencil = 'D2Q9'
omega = sp.Symbol('omega')
layout = 'fzyx'
# PDF Fields
pdfs, pdfs_tmp = ps.fields('pdfs(9), pdfs_tmp(9): [2D]', layout=layout)
# PDF Fields
pdfs, pdfs_tmp = ps.fields('pdfs(9), pdfs_tmp(9): [2D]', layout=layout)
# Velocity Output Field
velocity = ps.fields("velocity(2): [2D]", layout=layout)
output = {'velocity': velocity}
# Velocity Output Field
velocity = ps.fields("velocity(2): [2D]", layout=layout)
output = {'velocity': velocity}
# Optimization
optimization = {'cse_global': True,
'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
# ==================
# ==================
# Method Setup
# ==================
lbm_params = {'stencil': stencil,
'method': 'mrt_raw',
'relaxation_rates': [0, 0, 0, omega, omega, omega, 1, 1, 1],
'cumulant': True,
'compressible': True}
lbm_params = {'stencil': stencil,
'method': 'mrt_raw',
'relaxation_rates': [0, 0, 0, omega, omega, omega, 1, 1, 1],
'cumulant': True,
'compressible': True}
lbm_update_rule = create_lb_update_rule(optimization=optimization,
output=output,
**lbm_params)
lbm_update_rule = create_lb_update_rule(optimization=optimization,
output=output,
**lbm_params)
lbm_method = lbm_update_rule.method
lbm_method = lbm_update_rule.method
# ========================
# PDF Initialization
# ========================
# ========================
# PDF Initialization
# ========================
initial_rho = sp.Symbol('rho_0')
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,
velocity.center_vector,
pdfs.center_vector)
# =====================
# Code Generation
# =====================
# =====================
# Code Generation
# =====================
with CodeGeneration() as ctx:
if ctx.cuda:
target = 'gpu'
else:
target = 'cpu'
# LBM Sweep
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