From 166911b8c56d19d140a5e82d719623b69c8d4d1f Mon Sep 17 00:00:00 2001
From: Andreas Kloeckner <inform@tiker.net>
Date: Fri, 5 Oct 2012 14:10:16 -0400
Subject: [PATCH] Fix allocator visibility in tools, __init__, array.

---
 pyopencl/__init__.py         |  8 --------
 pyopencl/array.py            |  4 ++--
 pyopencl/tools.py            | 14 +++++++++++++-
 src/wrapper/wrap_mempool.cpp |  6 +++---
 4 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/pyopencl/__init__.py b/pyopencl/__init__.py
index cf56c2d3..2697fd4f 100644
--- a/pyopencl/__init__.py
+++ b/pyopencl/__init__.py
@@ -37,14 +37,6 @@ def compiler_output(text):
 
 
 
-class CLAllocator(DeferredAllocator):
-    def __init__(self, *args, **kwargs):
-        from warnings import warn
-        warn("pyopencl.CLAllocator is deprecated. "
-                "It will be continue to exist throughout the 2013.x "
-                "versions of PyOpenCL. Use {Deferred,Immediate}Allocator.",
-                DeprecationWarning, 2)
-        DeferredAllocator.__init__(self, *args, **kwargs)
 
 # {{{ Kernel
 
diff --git a/pyopencl/array.py b/pyopencl/array.py
index e4d46264..f3874c7d 100644
--- a/pyopencl/array.py
+++ b/pyopencl/array.py
@@ -191,14 +191,14 @@ def elwise_kernel_runner(kernel_getter):
 
 
 
-class DefaultAllocator(cl.DeferredAllocator):
+class DefaultAllocator(cl.tools.DeferredAllocator):
     def __init__(self, *args, **kwargs):
         from warnings import warn
         warn("pyopencl.array.DefaultAllocator is deprecated. "
                 "It will be continue to exist throughout the 2013.x "
                 "versions of PyOpenCL.",
                 DeprecationWarning, 2)
-        cl.DeferredAllocator.__init__(self, *args, **kwargs)
+        cl.tools.DeferredAllocator.__init__(self, *args, **kwargs)
 
 # }}}
 
diff --git a/pyopencl/tools.py b/pyopencl/tools.py
index ee8560af..22b782e6 100644
--- a/pyopencl/tools.py
+++ b/pyopencl/tools.py
@@ -51,7 +51,19 @@ get_or_register_dtype("cdouble_t", np.complex128)
 bitlog2 = cl.bitlog2
 
 PooledBuffer = cl.PooledBuffer
-CLAllocator = cl.CLAllocator
+
+from pyopencl._cl import _tools_DeferredAllocator as DeferredAllocator
+from pyopencl._cl import _tools_ImmediateAllocator as ImmediateAllocator
+
+class CLAllocator(DeferredAllocator):
+    def __init__(self, *args, **kwargs):
+        from warnings import warn
+        warn("pyopencl.tools.CLAllocator is deprecated. "
+                "It will be continue to exist throughout the 2013.x "
+                "versions of PyOpenCL. Use {Deferred,Immediate}Allocator.",
+                DeprecationWarning, 2)
+        DeferredAllocator.__init__(self, *args, **kwargs)
+
 MemoryPool = cl.MemoryPool
 
 
diff --git a/src/wrapper/wrap_mempool.cpp b/src/wrapper/wrap_mempool.cpp
index 411f9d0b..4eb6bd8d 100644
--- a/src/wrapper/wrap_mempool.cpp
+++ b/src/wrapper/wrap_mempool.cpp
@@ -237,7 +237,7 @@ void pyopencl_expose_mempool()
 
   {
     typedef cl_allocator_base cls;
-    py::class_<cls, boost::noncopyable> wrapper("AllocatorBase", py::no_init);
+    py::class_<cls, boost::noncopyable> wrapper("_tools_AllocatorBase", py::no_init);
     wrapper
       .def("__call__", allocator_call,
           py::return_value_policy<py::manage_new_object>())
@@ -247,7 +247,7 @@ void pyopencl_expose_mempool()
 
   {
     typedef cl_deferred_allocator cls;
-    py::class_<cls, py::bases<cl_allocator_base> > wrapper("DeferredAllocator",
+    py::class_<cls, py::bases<cl_allocator_base> > wrapper("_tools_DeferredAllocator",
         py::init<
           boost::shared_ptr<pyopencl::context> const &,
           py::optional<cl_mem_flags> >());
@@ -255,7 +255,7 @@ void pyopencl_expose_mempool()
 
   {
     typedef cl_immediate_allocator cls;
-    py::class_<cls, py::bases<cl_allocator_base> > wrapper("ImmediateAllocator",
+    py::class_<cls, py::bases<cl_allocator_base> > wrapper("_tools_ImmediateAllocator",
         py::init<pyopencl::command_queue &, py::optional<cl_mem_flags> >());
   }
 
-- 
GitLab