Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • ravi.k.ayyala/lbmpy
  • brendan-waters/lbmpy
  • anirudh.jonnalagadda/lbmpy
  • jbadwaik/lbmpy
  • alexander.reinauer/lbmpy
  • itischler/lbmpy
  • he66coqe/lbmpy
  • ev81oxyl/lbmpy
  • Bindgen/lbmpy
  • da15siwa/lbmpy
  • holzer/lbmpy
  • RudolfWeeber/lbmpy
  • pycodegen/lbmpy
13 results
Select Git revision
Show changes
Showing
with 1184 additions and 240 deletions
...@@ -49,6 +49,9 @@ class LatticeBoltzmannStep: ...@@ -49,6 +49,9 @@ class LatticeBoltzmannStep:
default_target=target, default_target=target,
parallel=False) parallel=False)
if lbm_config:
method_parameters['stencil'] = lbm_config.stencil
if 'stencil' not in method_parameters: if 'stencil' not in method_parameters:
method_parameters['stencil'] = LBStencil(Stencil.D2Q9) \ method_parameters['stencil'] = LBStencil(Stencil.D2Q9) \
if data_handling.dim == 2 else LBStencil(Stencil.D3Q27) if data_handling.dim == 2 else LBStencil(Stencil.D3Q27)
......
...@@ -27,16 +27,16 @@ import warnings ...@@ -27,16 +27,16 @@ import warnings
import numpy as np import numpy as np
# Optional packages cpuinfo, pycuda and psutil for hardware queries # Optional packages cpuinfo, cupy and psutil for hardware queries
try: try:
from cpuinfo import get_cpu_info from cpuinfo import get_cpu_info
except ImportError: except ImportError:
get_cpu_info = None get_cpu_info = None
try: try:
from pycuda.autoinit import device import cupy
except ImportError: except ImportError:
device = None cupy = None
try: try:
from psutil import virtual_memory from psutil import virtual_memory
...@@ -113,9 +113,11 @@ def memory_sizes_of_current_machine(): ...@@ -113,9 +113,11 @@ def memory_sizes_of_current_machine():
if 'l3_cache_size' in cpu_info: if 'l3_cache_size' in cpu_info:
result['L3'] = cpu_info['l3_cache_size'] result['L3'] = cpu_info['l3_cache_size']
if device: if cupy:
size = device.total_memory() / (1024 * 1024) for i in range(cupy.cuda.runtime.getDeviceCount()):
result['GPU'] = "{0:.0f} MB".format(size) device = cupy.cuda.Device(i)
size = device.mem_info[1] / (1024 * 1024)
result[f'GPU{i}'] = "{0:.0f} MB".format(size)
if virtual_memory: if virtual_memory:
mem = virtual_memory() mem = virtual_memory()
...@@ -124,7 +126,7 @@ def memory_sizes_of_current_machine(): ...@@ -124,7 +126,7 @@ def memory_sizes_of_current_machine():
if not result: if not result:
warnings.warn("Couldn't query for any local memory size." warnings.warn("Couldn't query for any local memory size."
"Install py-cpuinfo to get cache sizes, psutil for RAM size and pycuda for GPU memory size.") "Install py-cpuinfo to get cache sizes, psutil for RAM size and cupy for GPU memory size.")
return result return result
......
from .cumulantbasedmethod import CumulantBasedLbMethod
from .galilean_correction import add_galilean_correction
from .fourth_order_correction import add_fourth_order_correction
__all__ = ['CumulantBasedLbMethod', 'add_galilean_correction', 'add_fourth_order_correction']
import sympy as sp
from pystencils.simp.subexpression_insertion import insert_subexpressions
from warnings import warn
def insert_logs(ac, **kwargs):
def callback(exp):
rhs = exp.rhs
logs = rhs.atoms(sp.log)
return len(logs) > 0
return insert_subexpressions(ac, callback, **kwargs)
def insert_log_products(ac, **kwargs):
def callback(asm):
rhs = asm.rhs
if rhs.find(sp.log):
return True
return False
return insert_subexpressions(ac, callback, **kwargs)
def expand_post_collision_central_moments(ac):
if 'post_collision_monomial_central_moments' in ac.simplification_hints:
subexpr_dict = ac.subexpressions_dict
cm_symbols = ac.simplification_hints['post_collision_monomial_central_moments']
for s in cm_symbols:
if s in subexpr_dict:
subexpr_dict[s] = subexpr_dict[s].expand()
ac = ac.copy()
ac.set_sub_expressions_from_dict(subexpr_dict)
return ac
def check_for_logarithms(ac):
logs = ac.atoms(sp.log)
if len(logs) > 0:
warn("""There are logarithms remaining in your cumulant-based collision operator!
This will let your kernel's performance and numerical accuracy deterioate severly.
Either you have disabled simplification, or it unexpectedly failed.
If the presence of logarithms is intended, please inspect the kernel to make sure
if this warning can be ignored.
Otherwise, if setting `simplification='auto'` in your optimization config does not resolve
the problem, try a different parametrization, or contact the developers.""")
This diff is collapsed.
...@@ -286,7 +286,7 @@ def _get_relaxation_rates(collision_rule): ...@@ -286,7 +286,7 @@ def _get_relaxation_rates(collision_rule):
omega_s = get_shear_relaxation_rate(method) omega_s = get_shear_relaxation_rate(method)
# if the shear relaxation rate is not specified as a symbol look for its symbolic counter part in the subs dict # if the shear relaxation rate is not specified as a symbol look for its symbolic counter part in the subs dict
for symbolic_rr, rr in method.subs_dict_relxation_rate.items(): for symbolic_rr, rr in method.subs_dict_relaxation_rate.items():
if omega_s == rr: if omega_s == rr:
omega_s = symbolic_rr omega_s = symbolic_rr
......