From c603c35b760c38bd176d4a85da9dec22a8b6d6a5 Mon Sep 17 00:00:00 2001
From: Michael Kuron <m.kuron@gmx.de>
Date: Thu, 27 May 2021 15:29:32 +0200
Subject: [PATCH] check for warning when vectorizing without stride-one

---
 lbmpy_tests/test_fluctuating_lb.py | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/lbmpy_tests/test_fluctuating_lb.py b/lbmpy_tests/test_fluctuating_lb.py
index 76f4bdf9..8b5ce620 100644
--- a/lbmpy_tests/test_fluctuating_lb.py
+++ b/lbmpy_tests/test_fluctuating_lb.py
@@ -9,7 +9,7 @@ from lbmpy.moments import is_bulk_moment, is_shear_moment, get_order
 from pystencils.rng import PhiloxTwoDoubles
 
 import pytest
-from pystencils.backends.simd_instruction_sets import get_supported_instruction_sets
+from pystencils.backends.simd_instruction_sets import get_supported_instruction_sets, get_vector_instruction_set
 
 
 def single_component_maxwell(x1, x2, kT, mass):
@@ -274,14 +274,22 @@ def test_vectorization(assume_aligned, assume_inner_stride_one, assume_sufficien
                                       compressible=True,
                                       kernel_type='collide_only')
 
+    instruction_set = get_supported_instruction_sets()[-1]
     opts = {'cpu_openmp': False,
             'cpu_vectorize_info': {
-                'instruction_set': get_supported_instruction_sets()[0],
+                'instruction_set': instruction_set,
                 'assume_aligned': assume_aligned,
                 'assume_inner_stride_one': assume_inner_stride_one,
                 'assume_sufficient_line_padding': assume_sufficient_line_padding,
             },
             'target': 'cpu'}
 
-    code = ps.create_kernel(collision, **opts)
+    if not assume_inner_stride_one and 'storeS' not in get_vector_instruction_set('double', instruction_set):
+        with pytest.warns(UserWarning) as warn:
+            code = ps.create_kernel(collision, **opts)
+            assert 'Could not vectorize kernel because stride' in warn[0].message.args[0]
+    else:
+        with pytest.warns(None) as warn:
+            code = ps.create_kernel(collision, **opts)
+            assert len(warn) == 0
     code.compile()
-- 
GitLab