From 22152498897c941b1bf6a30d76998dd930a7df81 Mon Sep 17 00:00:00 2001
From: Yichao Yu <yyc1992@gmail.com>
Date: Tue, 24 Jun 2014 12:49:26 +0800
Subject: [PATCH] LocalMemory

---
 TODOs               |  1 -
 pyopencl/cffi_cl.py | 12 ++++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/TODOs b/TODOs
index 42528d35..cf163866 100644
--- a/TODOs
+++ b/TODOs
@@ -5,7 +5,6 @@
 - enqueue_nd_range_kernel size/offset mess
 
 - CommandQueue.set_property
-- ?LocalMemory
 - GLBuffer
 - GLRenderBuffer
 - GLTexture
diff --git a/pyopencl/cffi_cl.py b/pyopencl/cffi_cl.py
index 03c9ae5a..062324df 100644
--- a/pyopencl/cffi_cl.py
+++ b/pyopencl/cffi_cl.py
@@ -658,6 +658,15 @@ class cffi_array(np.ndarray):
         return self.__base
 
 
+class LocalMemory(object):
+    __slots__ = ('_size',)
+    def __init__(self, size):
+        self._size = size
+    @property
+    def size(self):
+        return self._size
+
+
 class MemoryObjectHolder(_Common):
     def get_host_array(self, shape, dtype, order="C"):
         dtype, shape, strides = _norm_shape_dtype(
@@ -941,6 +950,9 @@ class Kernel(_Common):
         elif isinstance(arg, Sampler):
             _handle_error(_lib.kernel__set_arg_sampler(self.ptr, arg_index,
                                                        arg.ptr))
+        elif isinstance(arg, LocalMemory):
+            _handle_error(_lib.kernel__set_arg_buf(self.ptr, arg_index,
+                                                   _ffi.NULL, arg.size))
         else:
             c_buf, size, _ = _c_buffer_from_obj(arg)
             _handle_error(_lib.kernel__set_arg_buf(self.ptr, arg_index,
-- 
GitLab