From 3d57c8e9a0867b8572c2faec719ce5669faac866 Mon Sep 17 00:00:00 2001
From: Jean-Baptiste Keck <Jean-Baptiste.Keck@imag.fr>
Date: Fri, 25 Oct 2019 23:46:47 +0200
Subject: [PATCH] better debug logs for remesh

---
 hysop/backend/device/codegen/functions/directional_remesh.py | 2 +-
 hysop/backend/device/codegen/kernels/directional_remesh.py   | 4 ++--
 .../backend/device/opencl/autotunable_kernels/remesh_dir.py  | 4 ++--
 .../device/opencl/operator/directional/advection_dir.py      | 4 +---
 hysop/operator/tests/test_directional_advection.py           | 5 ++---
 5 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/hysop/backend/device/codegen/functions/directional_remesh.py b/hysop/backend/device/codegen/functions/directional_remesh.py
index 3ed484d79..ff439bb0d 100644
--- a/hysop/backend/device/codegen/functions/directional_remesh.py
+++ b/hysop/backend/device/codegen/functions/directional_remesh.py
@@ -332,7 +332,7 @@ class DirectionalRemeshFunction(OpenClFunctionCodeGenerator):
                                         else:
                                             code = 'if({}) {{ {}; }}'.format(criteria, atom_add)
                                     else:
-                                        code = atom_add
+                                        code = '{};'.format(atom_add)
                                 else:
                                     inplace_add = '{} += {}'.format(cached_scalar[cache_idx], val)
                                     if (remesh_criteria_eps is not None):
diff --git a/hysop/backend/device/codegen/kernels/directional_remesh.py b/hysop/backend/device/codegen/kernels/directional_remesh.py
index c0d609c85..e28b37f82 100644
--- a/hysop/backend/device/codegen/kernels/directional_remesh.py
+++ b/hysop/backend/device/codegen/kernels/directional_remesh.py
@@ -220,7 +220,7 @@ class DirectionalRemeshKernelGenerator(KernelCodeGenerator):
         self.tuning_mode      = tuning_mode
 
         self.gencode()
-        self.edit()
+        #self.edit()
 
     def build_requirements(self, typegen, work_dim, itype, ftype,
             sboundary, nparticles, nscalars, nfields, group_scalars, symbolic_mode,
@@ -701,7 +701,7 @@ class DirectionalRemeshKernelGenerator(KernelCodeGenerator):
                     position_global_id.affect(al, i=0, align=True,
                             init='{} + {}'.format(particle_offset, position_grid_ghosts[0]))
                     if not is_inplace:
-                        #for _gid, _ghosts in zip(scalars_in_global_id, scalars_in_grid_ghosts):
+                        for _gid, _ghosts in zip(scalars_in_global_id, scalars_in_grid_ghosts):
                             _gid.affect(al, i=0, align=True,
                                 init='{} + {}'.format(particle_offset, _ghosts[0]))
                     for _gid, _ghosts in zip(scalars_data_out_global_id, scalars_data_out_grid_ghosts):
diff --git a/hysop/backend/device/opencl/autotunable_kernels/remesh_dir.py b/hysop/backend/device/opencl/autotunable_kernels/remesh_dir.py
index ac66bbf52..aee89fd51 100644
--- a/hysop/backend/device/opencl/autotunable_kernels/remesh_dir.py
+++ b/hysop/backend/device/opencl/autotunable_kernels/remesh_dir.py
@@ -270,7 +270,7 @@ class OpenClAutotunableDirectionalRemeshKernel(OpenClAutotunableKernel):
         force_atomics = extra_kwds['force_atomics']
 
         nparticles_options  = [1,2,4,8,16]
-        use_atomics_options = [False]#[True] if force_atomics else [True, False]
+        use_atomics_options = [True] if force_atomics else [True, False]
         if True in use_atomics_options:
             cl_env = self.cl_env
             msg=None
@@ -387,7 +387,7 @@ class OpenClAutotunableDirectionalRemeshKernel(OpenClAutotunableKernel):
                            use_atomics = use_atomics,
                            symbolic_mode = self.symbolic_mode,
                            tuning_mode = tuning_mode,
-                           debug_mode = True, 
+                           debug_mode = False, 
                            known_vars = known_vars)
         
         kernel_name = codegen.name
diff --git a/hysop/backend/device/opencl/operator/directional/advection_dir.py b/hysop/backend/device/opencl/operator/directional/advection_dir.py
index 89b3ad9be..819034fe5 100644
--- a/hysop/backend/device/opencl/operator/directional/advection_dir.py
+++ b/hysop/backend/device/opencl/operator/directional/advection_dir.py
@@ -11,7 +11,7 @@ from hysop.backend.device.opencl.opencl_kernel_launcher import OpenClKernelListL
 
 class OpenClDirectionalAdvection(DirectionalAdvectionBase, OpenClDirectionalOperator):
 
-    DEBUG=True
+    DEBUG=False
 
     @debug
     def __init__(self, force_atomics=False, relax_min_particles=False, remesh_criteria_eps=None,
@@ -188,8 +188,6 @@ class OpenClDirectionalAdvection(DirectionalAdvectionBase, OpenClDirectionalOper
             print 'OPENCL_Sout (before accumulation)'
             data = self.dadvected_fields_out.values()[0].data[0]
             print data.get(queue=queue)
-            import sys
-            sys.exit(1)
             print 'OPENCL_Sout (before accumulation, no ghosts)  ID={}'.format(id(data))
             self.dadvected_fields_out.values()[0].print_with_ghosts()
             self.accumulate_and_exchange(queue=queue).wait()
diff --git a/hysop/operator/tests/test_directional_advection.py b/hysop/operator/tests/test_directional_advection.py
index e06b1c041..7a5450553 100644
--- a/hysop/operator/tests/test_directional_advection.py
+++ b/hysop/operator/tests/test_directional_advection.py
@@ -117,8 +117,7 @@ class TestDirectionalAdvectionOperator(object):
         dt = velocity_cfl * np.divide(domain.length, shape).min()
         dt = ScalarParameter('dt', initial_value=dt, constant=True)
 
-        #ref_impl = Implementation.PYTHON
-        ref_impl = Implementation.OPENCL
+        ref_impl = Implementation.PYTHON
         implementations = DirectionalAdvection.implementations().keys()
         assert ref_impl in implementations
         implementations.remove(ref_impl)
@@ -242,7 +241,7 @@ class TestDirectionalAdvectionOperator(object):
                                     if (max_di>max_tol):
                                         print '\nFATAL ERROR: Could not match other implementation results.'
                                         print '\nComparisson failed at step {} and component {}:'.format(k,i)
-                                        for (j,dv) in dvin.iter_fields():
+                                        for (j,dv) in dvin.nd_iter():
                                             print 'VELOCITY INPUT {}'.format(DirectionLabels[j])
                                             print dv.sdata[dv.compute_slices]
                                         print 'SCALAR INPUT'
-- 
GitLab