xobjects 0.4.2__tar.gz → 0.4.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. {xobjects-0.4.2/xobjects.egg-info → xobjects-0.4.4}/PKG-INFO +1 -1
  2. xobjects-0.4.4/xobjects/_version.py +1 -0
  3. {xobjects-0.4.2 → xobjects-0.4.4}/xobjects/context.py +14 -3
  4. {xobjects-0.4.2 → xobjects-0.4.4}/xobjects/context_cpu.py +6 -0
  5. {xobjects-0.4.2 → xobjects-0.4.4}/xobjects/context_cupy.py +3 -1
  6. {xobjects-0.4.2 → xobjects-0.4.4}/xobjects/context_pyopencl.py +8 -1
  7. {xobjects-0.4.2 → xobjects-0.4.4/xobjects.egg-info}/PKG-INFO +1 -1
  8. xobjects-0.4.2/xobjects/_version.py +0 -1
  9. {xobjects-0.4.2 → xobjects-0.4.4}/LICENSE +0 -0
  10. {xobjects-0.4.2 → xobjects-0.4.4}/pyproject.toml +0 -0
  11. {xobjects-0.4.2 → xobjects-0.4.4}/setup.cfg +0 -0
  12. {xobjects-0.4.2 → xobjects-0.4.4}/setup.py +0 -0
  13. {xobjects-0.4.2 → xobjects-0.4.4}/tests/test_align.py +0 -0
  14. {xobjects-0.4.2 → xobjects-0.4.4}/tests/test_array.py +0 -0
  15. {xobjects-0.4.2 → xobjects-0.4.4}/tests/test_buffer.py +0 -0
  16. {xobjects-0.4.2 → xobjects-0.4.4}/tests/test_capi.py +0 -0
  17. {xobjects-0.4.2 → xobjects-0.4.4}/tests/test_chunk.py +0 -0
  18. {xobjects-0.4.2 → xobjects-0.4.4}/tests/test_context_opencl.py +0 -0
  19. {xobjects-0.4.2 → xobjects-0.4.4}/tests/test_hybrid_class.py +0 -0
  20. {xobjects-0.4.2 → xobjects-0.4.4}/tests/test_kernel.py +0 -0
  21. {xobjects-0.4.2 → xobjects-0.4.4}/tests/test_linked_array.py +0 -0
  22. {xobjects-0.4.2 → xobjects-0.4.4}/tests/test_nplike_arrays.py +0 -0
  23. {xobjects-0.4.2 → xobjects-0.4.4}/tests/test_ref.py +0 -0
  24. {xobjects-0.4.2 → xobjects-0.4.4}/tests/test_scalars.py +0 -0
  25. {xobjects-0.4.2 → xobjects-0.4.4}/tests/test_shared_memory.py +0 -0
  26. {xobjects-0.4.2 → xobjects-0.4.4}/tests/test_strides.py +0 -0
  27. {xobjects-0.4.2 → xobjects-0.4.4}/tests/test_string.py +0 -0
  28. {xobjects-0.4.2 → xobjects-0.4.4}/tests/test_struct.py +0 -0
  29. {xobjects-0.4.2 → xobjects-0.4.4}/tests/test_to_json.py +0 -0
  30. {xobjects-0.4.2 → xobjects-0.4.4}/tests/test_typeutils.py +0 -0
  31. {xobjects-0.4.2 → xobjects-0.4.4}/tests/test_unionref.py +0 -0
  32. {xobjects-0.4.2 → xobjects-0.4.4}/xobjects/__init__.py +0 -0
  33. {xobjects-0.4.2 → xobjects-0.4.4}/xobjects/_patch_pyopencl_array.py +0 -0
  34. {xobjects-0.4.2 → xobjects-0.4.4}/xobjects/array.py +0 -0
  35. {xobjects-0.4.2 → xobjects-0.4.4}/xobjects/capi.py +0 -0
  36. {xobjects-0.4.2 → xobjects-0.4.4}/xobjects/general.py +0 -0
  37. {xobjects-0.4.2 → xobjects-0.4.4}/xobjects/hybrid_class.py +0 -0
  38. {xobjects-0.4.2 → xobjects-0.4.4}/xobjects/linkedarray.py +0 -0
  39. {xobjects-0.4.2 → xobjects-0.4.4}/xobjects/ref.py +0 -0
  40. {xobjects-0.4.2 → xobjects-0.4.4}/xobjects/scalar.py +0 -0
  41. {xobjects-0.4.2 → xobjects-0.4.4}/xobjects/specialize_source.py +0 -0
  42. {xobjects-0.4.2 → xobjects-0.4.4}/xobjects/string.py +0 -0
  43. {xobjects-0.4.2 → xobjects-0.4.4}/xobjects/struct.py +0 -0
  44. {xobjects-0.4.2 → xobjects-0.4.4}/xobjects/test_helpers.py +0 -0
  45. {xobjects-0.4.2 → xobjects-0.4.4}/xobjects/typeutils.py +0 -0
  46. {xobjects-0.4.2 → xobjects-0.4.4}/xobjects/union.py +0 -0
  47. {xobjects-0.4.2 → xobjects-0.4.4}/xobjects.egg-info/SOURCES.txt +0 -0
  48. {xobjects-0.4.2 → xobjects-0.4.4}/xobjects.egg-info/dependency_links.txt +0 -0
  49. {xobjects-0.4.2 → xobjects-0.4.4}/xobjects.egg-info/requires.txt +0 -0
  50. {xobjects-0.4.2 → xobjects-0.4.4}/xobjects.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xobjects
3
- Version: 0.4.2
3
+ Version: 0.4.4
4
4
  Summary: In-memory serialization and code generator for CPU and GPU
5
5
  Home-page: https://xsuite.readthedocs.io/
6
6
  Download-URL: https://pypi.python.org/pypi/xobjects
@@ -0,0 +1 @@
1
+ __version__ = "0.4.4"
@@ -210,19 +210,30 @@ class XContext(ABC):
210
210
 
211
211
  def __init__(self):
212
212
  self._kernels = KernelDict()
213
- self._buffers = []
213
+ self._buffers = weakref.WeakSet()
214
+ self._allocations = 0
214
215
 
215
216
  def __str__(self):
216
217
  return type(self).__name__
217
218
 
218
219
  def new_buffer(self, capacity=1048576):
219
220
  buf = self._make_buffer(capacity=capacity)
220
- self.buffers.append(weakref.finalize(buf, log.debug, "free buf"))
221
+ self._buffers.add(buf)
222
+ self._allocations += 1
221
223
  return buf
222
224
 
225
+ def __getstate__(self):
226
+ state = self.__dict__
227
+ del state["_buffers"]
228
+ return state
229
+
230
+ def __setstate__(self, state):
231
+ self.__dict__.update(state)
232
+ self._buffers = weakref.WeakSet()
233
+
223
234
  @property
224
235
  def buffers(self):
225
- return self._buffers
236
+ return list(self._buffers)
226
237
 
227
238
  @property
228
239
  def kernels(self):
@@ -10,6 +10,7 @@ import sysconfig
10
10
  import uuid
11
11
  from pathlib import Path
12
12
  from typing import Callable, Dict, List, Sequence, Tuple
13
+ import weakref
13
14
 
14
15
  from .general import _print
15
16
 
@@ -106,6 +107,9 @@ class LinkedArrayCpu(BaseLinkedArray, np.ndarray):
106
107
  order="C",
107
108
  )
108
109
 
110
+ def copy(self):
111
+ return np.array(self)
112
+
109
113
 
110
114
  def _so_for_module_name(name, containing_dir=".") -> Path:
111
115
  # The so file name is something like:
@@ -642,10 +646,12 @@ class ContextCpu(XContext):
642
646
  def __getstate__(self):
643
647
  state = self.__dict__.copy()
644
648
  state["_kernels"] = {}
649
+ del state["_buffers"]
645
650
  return state
646
651
 
647
652
  def __setstate__(self, state):
648
653
  self.__dict__.update(state)
654
+ self._buffers = weakref.WeakSet()
649
655
 
650
656
 
651
657
  class BufferByteArray(XBuffer):
@@ -473,6 +473,9 @@ class ContextCupy(XContext):
473
473
 
474
474
  return out_kernels
475
475
 
476
+ def __str__(self):
477
+ return f"{type(self).__name__}:{cupy.cuda.get_device_id()}"
478
+
476
479
  def nparray_to_context_array(self, arr):
477
480
  """
478
481
  Copies a numpy array to the device memory.
@@ -631,7 +634,6 @@ class KernelCupy(object):
631
634
  def __init__(
632
635
  self, function, description, block_size, context, shared_mem_size_bytes
633
636
  ):
634
-
635
637
  self.function = function
636
638
  self.description = description
637
639
  self.block_size = block_size
@@ -218,7 +218,9 @@ class ContextPyopencl(XContext):
218
218
  with open(save_source_as, "w") as fid:
219
219
  fid.write(specialized_source)
220
220
 
221
- prg = cl.Program(self.context, specialized_source).build()
221
+ prg = cl.Program(self.context, specialized_source).build(
222
+ options="-cl-std=CL2.0",
223
+ )
222
224
 
223
225
  out_kernels = {}
224
226
  for pyname, kernel in kernel_descriptions.items():
@@ -236,6 +238,11 @@ class ContextPyopencl(XContext):
236
238
 
237
239
  return out_kernels
238
240
 
241
+ def __str__(self):
242
+ platform_id = cl.get_platforms().index(self.platform)
243
+ device_id = self.platform.get_devices().index(self.device)
244
+ return f"{type(self).__name__}:{platform_id}.{device_id}"
245
+
239
246
  def nparray_to_context_array(self, arr):
240
247
  """
241
248
  Copies a numpy array to the device memory.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xobjects
3
- Version: 0.4.2
3
+ Version: 0.4.4
4
4
  Summary: In-memory serialization and code generator for CPU and GPU
5
5
  Home-page: https://xsuite.readthedocs.io/
6
6
  Download-URL: https://pypi.python.org/pypi/xobjects
@@ -1 +0,0 @@
1
- __version__ = "0.4.2"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes