From 78a5a2a1867d947fefabe59c9796c980cf193a6b Mon Sep 17 00:00:00 2001
From: Jean-Baptiste Keck <jean-baptiste.keck@imag.fr>
Date: Mon, 19 Nov 2018 20:14:53 +0100
Subject: [PATCH] fixed import for pyopencl using pybind

---
 examples/particles_above_salt/particles_above_salt_bc_3d.py | 2 +-
 .../backend/device/codegen/kernels/tests/test_transpose.py  | 2 +-
 hysop/backend/device/device_buffer.py                       | 2 +-
 hysop/backend/device/opencl/__init__.py                     | 3 ---
 hysop/backend/device/opencl/opencl_allocator.py             | 2 +-
 hysop/backend/device/opencl/opencl_buffer.py                | 2 +-
 hysop/backend/device/opencl/opencl_device.py                | 2 +-
 hysop/backend/device/opencl/opencl_kernel_autotuner.py      | 2 +-
 hysop/core/memory/buffer.py                                 | 6 ------
 requirements.txt                                            | 2 ++
 10 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/examples/particles_above_salt/particles_above_salt_bc_3d.py b/examples/particles_above_salt/particles_above_salt_bc_3d.py
index 195dea731..014f03bf8 100644
--- a/examples/particles_above_salt/particles_above_salt_bc_3d.py
+++ b/examples/particles_above_salt/particles_above_salt_bc_3d.py
@@ -74,7 +74,7 @@ def compute(args):
     if (dim==2):
         (Sc, tau, Vp, Rs, Xo, Xn, N) = (0.70,  25, 0.04, 2.0, (-600,0), (600,750), (1537, 512))
     elif (dim==3):
-        (Sc, tau, Vp, Rs, Xo, Xn, N) = (15.00, 25, 0.04, 2.0, (-110,0,0), (65,100,100), (3073, 1024, 1024))
+        (Sc, tau, Vp, Rs, Xo, Xn, N) = (30.00, 25, 0.04, 2.0, (-110,0,0), (65,100,100), (3073, 1024, 1024))
     else:
         raise NotImplementedError
 
diff --git a/hysop/backend/device/codegen/kernels/tests/test_transpose.py b/hysop/backend/device/codegen/kernels/tests/test_transpose.py
index f0e3bbc91..8ec832c65 100644
--- a/hysop/backend/device/codegen/kernels/tests/test_transpose.py
+++ b/hysop/backend/device/codegen/kernels/tests/test_transpose.py
@@ -365,7 +365,7 @@ class TestTranspose(object):
                         buffers = (('Tin',  Tin_cpu,  Tin,  in_view),
                                    ('Tout', Tout_cpu, Tout, out_view))
                     good, err_buffers = self._cmp_buffers(buffers,dak,dim)
-                except cl.cffi_cl.RuntimeError as error:
+                except cl._cl.RuntimeError as error:
                     e = error
                     print 'ERROR: ',e
                     good = False
diff --git a/hysop/backend/device/device_buffer.py b/hysop/backend/device/device_buffer.py
index 861361b5b..8f81290a7 100644
--- a/hysop/backend/device/device_buffer.py
+++ b/hysop/backend/device/device_buffer.py
@@ -6,4 +6,4 @@ class DeviceBuffer(Buffer):
     """
     Abstract device buffer class.
     """
-    __metaclass__=ABCMeta
+    pass
diff --git a/hysop/backend/device/opencl/__init__.py b/hysop/backend/device/opencl/__init__.py
index 05c7889d2..07d478dcd 100644
--- a/hysop/backend/device/opencl/__init__.py
+++ b/hysop/backend/device/opencl/__init__.py
@@ -51,9 +51,6 @@ clElementwise = pyopencl.elementwise
 clCharacterize = pyopencl.characterize
 """PyOpenCL characterize"""
 
-from pyopencl._cffi import ffi as cl_ffi, lib as cl_lib
-from pyopencl import cffi_cl
-
 if ('CLFFT_REQUEST_NOMEMALLOC' not in os.environ):
     os.environ['CLFFT_REQUEST_NOMEMALLOC'] = '1'
 if ('CLFFT_CACHE_PATH' not in os.environ):
diff --git a/hysop/backend/device/opencl/opencl_allocator.py b/hysop/backend/device/opencl/opencl_allocator.py
index d1cb7dc7e..e3137b8bb 100644
--- a/hysop/backend/device/opencl/opencl_allocator.py
+++ b/hysop/backend/device/opencl/opencl_allocator.py
@@ -85,7 +85,7 @@ class OpenClImmediateAllocator(OpenClAllocator):
         buf = OpenClBuffer(context=self.context, mem_flags=self.mem_flags, size=nbytes)
 
         try:
-            from pyopencl.cffi_cl import _enqueue_write_buffer
+            from pyopencl._cl import _enqueue_write_buffer
             _enqueue_write_buffer(
                     self.queue, buf,
                     self._zero[:min(len(self._zero), nbytes)],
diff --git a/hysop/backend/device/opencl/opencl_buffer.py b/hysop/backend/device/opencl/opencl_buffer.py
index c05186311..42b7e52eb 100644
--- a/hysop/backend/device/opencl/opencl_buffer.py
+++ b/hysop/backend/device/opencl/opencl_buffer.py
@@ -1,6 +1,6 @@
 from hysop.core.memory.buffer import PooledBuffer
 from hysop.backend.device.device_buffer import DeviceBuffer
-from hysop.backend.device.opencl import cl, cl_ffi, cl_lib, cffi_cl
+from hysop.backend.device.opencl import cl
 
 class OpenClBuffer(DeviceBuffer, cl.Buffer):
     """
diff --git a/hysop/backend/device/opencl/opencl_device.py b/hysop/backend/device/opencl/opencl_device.py
index b83bd0181..6539b6cac 100644
--- a/hysop/backend/device/opencl/opencl_device.py
+++ b/hysop/backend/device/opencl/opencl_device.py
@@ -152,7 +152,7 @@ class OpenClDevice(LogicalDevice):
                 if isinstance(val, str):
                     val = val.strip()
                 setattr(self, '_'+attr, val)
-            except (cl.cffi_cl.LogicError, AttributeError):
+            except (cl._cl.LogicError, AttributeError):
                 _not_found += (attr,)
                 setattr(self, '_'+attr, UnknownDeviceAttribute())
             except RuntimeError as e:
diff --git a/hysop/backend/device/opencl/opencl_kernel_autotuner.py b/hysop/backend/device/opencl/opencl_kernel_autotuner.py
index d3edab02c..dd9256ff9 100644
--- a/hysop/backend/device/opencl/opencl_kernel_autotuner.py
+++ b/hysop/backend/device/opencl/opencl_kernel_autotuner.py
@@ -145,7 +145,7 @@ class OpenClKernelAutotuner(KernelAutotuner):
                 while(stats.nruns < target_nruns) and (not pruned):
                     try:
                         evt = cl.enqueue_nd_range_kernel(queue, kernel, global_size, local_size)
-                    except cl.cffi_cl.RuntimeError:
+                    except cl._cl.RuntimeError:
                         raise KernelGenerationError()
                     evt.wait()
                     stats += OpenClKernelStatistics(events=[evt])
diff --git a/hysop/core/memory/buffer.py b/hysop/core/memory/buffer.py
index e33cbf23e..c95c52c6e 100644
--- a/hysop/core/memory/buffer.py
+++ b/hysop/core/memory/buffer.py
@@ -16,7 +16,6 @@ class Buffer(object):
     """
     
     #/!\ ptr, size and int_ptr properties should be redefined in child classes.
-    __metaclass__ = ABCMeta
     _DEBUG=False
 
     def __init__(self, size, **kwds):
@@ -73,11 +72,6 @@ class PooledBuffer(Buffer):
     """
     Memory pool allocated buffer wrapper.
     """
-    __metaclass__ = ABCMeta
-
-    """
-    Extra flag for debugging PooledBuffers.
-    """
 
     def __init__(self, pool, buf, alloc_sz, size, alignment, **kwds):
         """
diff --git a/requirements.txt b/requirements.txt
index c0c1b05dc..b44b42fb4 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,3 +1,4 @@
+wheel
 numpy
 scipy
 sympy
@@ -13,6 +14,7 @@ ansicolors
 backports.weakref
 argparse_color_formatter
 primefac
+pybind11
 pyopencl
 pyfftw
 mpi4py
-- 
GitLab