From d8d06ce468852963c8e32006aa23560fda7aabf2 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Sun, 24 Apr 2011 03:43:59 -0400 Subject: [PATCH] Re-add caching for array flags. Run GC in test to deal with ensuing ref loops. --- pyopencl/array.py | 4 ++++ pyopencl/tools.py | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/pyopencl/array.py b/pyopencl/array.py index a0f7805c..a93c947e 100644 --- a/pyopencl/array.py +++ b/pyopencl/array.py @@ -216,16 +216,19 @@ class _ArrayFlags: self.array = ary @property + @memoize_method def f_contiguous(self): return self.array.strides == _f_contiguous_strides( self.array.dtype.itemsize, self.array.shape) @property + @memoize_method def c_contiguous(self): return self.array.strides == _c_contiguous_strides( self.array.dtype.itemsize, self.array.shape) @property + @memoize_method def forc(self): return self.f_contiguous or self.c_contiguous @@ -332,6 +335,7 @@ class Array(object): self.context = self.data.context @property + @memoize_method def flags(self): return _ArrayFlags(self) diff --git a/pyopencl/tools.py b/pyopencl/tools.py index 8a25b801..a124600f 100644 --- a/pyopencl/tools.py +++ b/pyopencl/tools.py @@ -72,6 +72,12 @@ def pytest_generate_tests_for_pyopencl(metafunc): self.device = device def __call__(self): + # Get rid of leftovers from past tests. + # CL implementations are surprisingly limited in how many + # simultaneous contexts they allow... + from gc import collect + collect() + return cl.Context([device]) def __str__(self): -- GitLab