From 1aad0dcbb44bfc3d557b7146f673b766e9d54c27 Mon Sep 17 00:00:00 2001
From: Christoph Rettinger <christoph.rettinger@fau.de>
Date: Mon, 22 Jun 2020 09:40:53 +0200
Subject: [PATCH] Added warning if no SIMD instruction could be determined,
 adapted field layouts in all tests and benchmarks

---
 apps/benchmarks/FluidParticleCoupling/GeneratedLBM.py        | 5 +++--
 .../FluidParticleCoupling/GeneratedLBMWithForce.py           | 4 ++--
 python/pystencils_walberla/codegen.py                        | 4 +++-
 tests/lbm/codegen/FieldLayoutAndVectorizationTest.py         | 1 +
 tests/lbm/codegen/FluctuatingMRT.py                          | 2 +-
 tests/lbm/codegen/LbCodeGenerationExample.py                 | 2 +-
 6 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/apps/benchmarks/FluidParticleCoupling/GeneratedLBM.py b/apps/benchmarks/FluidParticleCoupling/GeneratedLBM.py
index e9ecd8375..7992bcdd9 100644
--- a/apps/benchmarks/FluidParticleCoupling/GeneratedLBM.py
+++ b/apps/benchmarks/FluidParticleCoupling/GeneratedLBM.py
@@ -10,6 +10,7 @@ from lbmpy.stencils import get_stencil
 
 
 with CodeGeneration() as ctx:
+
     omegaVisc = sp.Symbol("omega_visc")
     omegaBulk = ps.fields("omega_bulk: [3D]", layout='fzyx')
     omegaMagic = sp.Symbol("omega_magic")
@@ -37,8 +38,8 @@ with CodeGeneration() as ctx:
     #print(methodWithForce.relaxation_rates)
     #print(methodWithForce.moment_matrix)
 
-    collision_rule = create_lb_collision_rule(lb_method=methodWithForce)
-    generate_lattice_model(ctx, 'GeneratedLBM', collision_rule)
+    collision_rule = create_lb_collision_rule(lb_method=methodWithForce, optimization={'cse_global': True})
+    generate_lattice_model(ctx, 'GeneratedLBM', collision_rule, field_layout='fzyx')
 
 
 
diff --git a/apps/benchmarks/FluidParticleCoupling/GeneratedLBMWithForce.py b/apps/benchmarks/FluidParticleCoupling/GeneratedLBMWithForce.py
index c63157fda..9162d1cfe 100644
--- a/apps/benchmarks/FluidParticleCoupling/GeneratedLBMWithForce.py
+++ b/apps/benchmarks/FluidParticleCoupling/GeneratedLBMWithForce.py
@@ -41,5 +41,5 @@ with CodeGeneration() as ctx:
     #print(methodWithForce.relaxation_rates)
     #print(methodWithForce.moment_matrix)
 
-    collision_rule = create_lb_collision_rule(lb_method=methodWithForce)
-    generate_lattice_model(ctx, 'GeneratedLBMWithForce', collision_rule)
+    collision_rule = create_lb_collision_rule(lb_method=methodWithForce, optimization={'cse_global': True})
+    generate_lattice_model(ctx, 'GeneratedLBMWithForce', collision_rule, field_layout='fzyx')
diff --git a/python/pystencils_walberla/codegen.py b/python/pystencils_walberla/codegen.py
index d73b502c5..7b94dc955 100644
--- a/python/pystencils_walberla/codegen.py
+++ b/python/pystencils_walberla/codegen.py
@@ -1,3 +1,4 @@
+import warnings
 from collections import OrderedDict, defaultdict
 from itertools import product
 from typing import Dict, Optional, Sequence, Tuple
@@ -331,8 +332,9 @@ def get_vectorize_instruction_set(generation_context):
     if generation_context.optimize_for_localhost:
         supported_instruction_sets = get_supported_instruction_sets()
         if supported_instruction_sets:
-            return get_supported_instruction_sets()[-1]
+            return supported_instruction_sets[-1]
         else:  # if cpuinfo package is not installed
+            warnings.warn("Could not obtain supported vectorization instruction sets - defaulting to sse")
             return 'sse'
     else:
         return None
diff --git a/tests/lbm/codegen/FieldLayoutAndVectorizationTest.py b/tests/lbm/codegen/FieldLayoutAndVectorizationTest.py
index 1bd424e79..5e43eee55 100644
--- a/tests/lbm/codegen/FieldLayoutAndVectorizationTest.py
+++ b/tests/lbm/codegen/FieldLayoutAndVectorizationTest.py
@@ -22,3 +22,4 @@ with CodeGeneration() as ctx:
     for conf in configurations:
         generate_lattice_model(ctx, 'FieldLayoutAndVectorizationTest_'+conf.name+'_LatticeModel', collision_rule,
                                field_layout=conf.field_layout, refinement_scaling=None, cpu_vectorize_info=conf.vectorization_dict)
+
diff --git a/tests/lbm/codegen/FluctuatingMRT.py b/tests/lbm/codegen/FluctuatingMRT.py
index f6b0074f2..a5ffa9baf 100644
--- a/tests/lbm/codegen/FluctuatingMRT.py
+++ b/tests/lbm/codegen/FluctuatingMRT.py
@@ -9,7 +9,7 @@ from lbmpy_walberla import generate_lattice_model
 with CodeGeneration() as ctx:
     omega_shear = sp.symbols("omega_shear")
     temperature = sp.symbols("temperature")
-    force_field, vel_field = ps.fields("force(3), velocity(3): [3D]", layout='fzyx')
+    force_field, vel_field = ps.fields("force(3), velocity(3): [3D]", layout='zyxf')
 
     def rr_getter(moment_group):
         is_shear = [is_shear_moment(m, 3) for m in moment_group]
diff --git a/tests/lbm/codegen/LbCodeGenerationExample.py b/tests/lbm/codegen/LbCodeGenerationExample.py
index 67aed714e..259a9787e 100644
--- a/tests/lbm/codegen/LbCodeGenerationExample.py
+++ b/tests/lbm/codegen/LbCodeGenerationExample.py
@@ -7,7 +7,7 @@ from lbmpy_walberla import RefinementScaling, generate_boundary, generate_lattic
 
 with CodeGeneration() as ctx:
     omega, omega_free = sp.symbols("omega, omega_free")
-    force_field, vel_field, omega_out = ps.fields("force(3), velocity(3), omega_out: [3D]", layout='fzyx')
+    force_field, vel_field, omega_out = ps.fields("force(3), velocity(3), omega_out: [3D]", layout='zyxf')
 
     # the collision rule of the LB method where the some advanced features
     collision_rule = create_lb_collision_rule(
-- 
GitLab