diff --git a/tests/test_shared_memory.py b/tests/test_shared_memory.py index cf077c1..4f2e6fc 100644 --- a/tests/test_shared_memory.py +++ b/tests/test_shared_memory.py @@ -4,9 +4,7 @@ def test_shared_memory(): for test_context in xo.context.get_test_contexts(): - print(repr(test_context)) - if isinstance(test_context, xo.ContextCupy): test_context.default_block_size = 2 test_context.default_shared_mem_size_bytes = ( @@ -44,10 +42,10 @@ class TestElement(xo.HybridClass): // reduction with an array of 4 doubles using 2 blocks each 2 threads // use reduction with interleaved addressing: https://developer.download.nvidia.com/assets/cuda/files/reduction.pdf // all threads within a block have access to shared memory - + unsigned int tid = threadIdx.x; // thread ID within the block: 0,1 unsigned int gid = blockIdx.x*blockDim.x + threadIdx.x; // global thread ID: 0,1,2,3 - + // init shared memory with chunk of input array extern __shared__ double sdata[2]; sdata[tid] = input_arr[gid]; @@ -68,7 +66,6 @@ class TestElement(xo.HybridClass): def __init__( self, _context=None, _buffer=None, _offset=None, _xobject=None ): - if _xobject is not None: self.xoinitialize( _xobject=_xobject, diff --git a/xobjects/_version.py b/xobjects/_version.py index c49a95c..75cf783 100644 --- a/xobjects/_version.py +++ b/xobjects/_version.py @@ -1 +1 @@ -__version__ = "0.2.8" +__version__ = "0.2.9" diff --git a/xobjects/hybrid_class.py b/xobjects/hybrid_class.py index 2f0a743..2b504c6 100644 --- a/xobjects/hybrid_class.py +++ b/xobjects/hybrid_class.py @@ -301,7 +301,13 @@ def to_dict(self, copy_to_cpu=True): if hasattr(obj, "_store_in_to_dict"): for nn in obj._store_in_to_dict: - out[nn] = getattr(obj, nn) + ww = getattr(obj, nn) + if hasattr(ww, "to_dict"): + out[nn] = ww.to_dict() + elif hasattr(ww, "_to_dict"): + out[nn] = ww._to_dict() + else: + out[nn] = ww return out