pyopencl 2024.2.7__tar.gz → 2024.3__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.

Potentially problematic release.


This version of pyopencl might be problematic. Click here for more details.

Files changed (136) hide show
  1. {pyopencl-2024.2.7 → pyopencl-2024.3}/.gitlab-ci.yml +8 -7
  2. {pyopencl-2024.2.7 → pyopencl-2024.3}/.test-conda-env-py3.yml +0 -1
  3. {pyopencl-2024.2.7 → pyopencl-2024.3}/CMakeLists.txt +6 -5
  4. {pyopencl-2024.2.7 → pyopencl-2024.3}/PKG-INFO +11 -8
  5. {pyopencl-2024.2.7 → pyopencl-2024.3}/contrib/cldis.py +4 -4
  6. {pyopencl-2024.2.7 → pyopencl-2024.3}/contrib/fortran-to-opencl/translate.py +21 -15
  7. {pyopencl-2024.2.7 → pyopencl-2024.3}/doc/make_constants.py +1 -1
  8. {pyopencl-2024.2.7 → pyopencl-2024.3}/doc/runtime_memory.rst +8 -27
  9. {pyopencl-2024.2.7 → pyopencl-2024.3}/doc/runtime_platform.rst +12 -7
  10. {pyopencl-2024.2.7 → pyopencl-2024.3}/doc/runtime_program.rst +8 -0
  11. {pyopencl-2024.2.7 → pyopencl-2024.3}/examples/black-hole-accretion.py +1 -1
  12. {pyopencl-2024.2.7 → pyopencl-2024.3}/examples/demo_meta_codepy.py +12 -2
  13. {pyopencl-2024.2.7 → pyopencl-2024.3}/examples/dump-properties.py +2 -2
  14. {pyopencl-2024.2.7 → pyopencl-2024.3}/examples/ipython-demo.ipynb +5 -4
  15. {pyopencl-2024.2.7 → pyopencl-2024.3}/examples/n-body.py +8 -8
  16. {pyopencl-2024.2.7 → pyopencl-2024.3}/examples/pi-monte-carlo.py +4 -3
  17. {pyopencl-2024.2.7 → pyopencl-2024.3}/examples/svm.py +4 -2
  18. {pyopencl-2024.2.7 → pyopencl-2024.3}/examples/transpose.py +1 -2
  19. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/__init__.py +127 -122
  20. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/_mymako.py +3 -3
  21. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/algorithm.py +10 -7
  22. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/array.py +50 -40
  23. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/bitonic_sort.py +3 -1
  24. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/bitonic_sort_templates.py +1 -1
  25. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/cache.py +23 -22
  26. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/capture_call.py +5 -4
  27. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/clrandom.py +1 -0
  28. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/compyte/dtypes.py +4 -4
  29. pyopencl-2024.3/pyopencl/compyte/pyproject.toml +54 -0
  30. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/elementwise.py +9 -2
  31. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/invoker.py +11 -9
  32. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/ipython_ext.py +1 -1
  33. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/reduction.py +16 -10
  34. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/scan.py +38 -22
  35. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/tools.py +23 -13
  36. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyproject.toml +123 -28
  37. {pyopencl-2024.2.7 → pyopencl-2024.3}/src/wrap_cl.hpp +87 -5
  38. {pyopencl-2024.2.7 → pyopencl-2024.3}/src/wrap_cl_part_2.cpp +38 -9
  39. {pyopencl-2024.2.7 → pyopencl-2024.3}/test/test_algorithm.py +32 -24
  40. {pyopencl-2024.2.7 → pyopencl-2024.3}/test/test_array.py +21 -20
  41. {pyopencl-2024.2.7 → pyopencl-2024.3}/test/test_arrays_in_structs.py +3 -2
  42. {pyopencl-2024.2.7 → pyopencl-2024.3}/test/test_clmath.py +6 -5
  43. {pyopencl-2024.2.7 → pyopencl-2024.3}/test/test_clrandom.py +3 -2
  44. {pyopencl-2024.2.7 → pyopencl-2024.3}/test/test_enqueue_copy.py +4 -3
  45. {pyopencl-2024.2.7 → pyopencl-2024.3}/test/test_wrapper.py +13 -11
  46. pyopencl-2024.2.7/pyopencl/compyte/.git +0 -1
  47. pyopencl-2024.2.7/pyopencl/compyte/ndarray/Makefile +0 -31
  48. pyopencl-2024.2.7/pyopencl/compyte/ndarray/__init__.py +0 -0
  49. pyopencl-2024.2.7/pyopencl/compyte/ndarray/gen_elemwise.py +0 -1907
  50. pyopencl-2024.2.7/pyopencl/compyte/ndarray/gen_reduction.py +0 -1511
  51. pyopencl-2024.2.7/pyopencl/compyte/ndarray/gpu_ndarray.h +0 -35
  52. pyopencl-2024.2.7/pyopencl/compyte/ndarray/pygpu_language.h +0 -207
  53. pyopencl-2024.2.7/pyopencl/compyte/ndarray/pygpu_language_cuda.cu +0 -622
  54. pyopencl-2024.2.7/pyopencl/compyte/ndarray/pygpu_language_opencl.cpp +0 -317
  55. pyopencl-2024.2.7/pyopencl/compyte/ndarray/pygpu_ndarray.cpp +0 -1546
  56. pyopencl-2024.2.7/pyopencl/compyte/ndarray/pygpu_ndarray.h +0 -71
  57. pyopencl-2024.2.7/pyopencl/compyte/ndarray/pygpu_ndarray_object.h +0 -232
  58. pyopencl-2024.2.7/pyopencl/compyte/ndarray/setup_opencl.py +0 -101
  59. pyopencl-2024.2.7/pyopencl/compyte/ndarray/test_gpu_elemwise.py +0 -411
  60. pyopencl-2024.2.7/pyopencl/compyte/ndarray/test_gpu_ndarray.py +0 -487
  61. pyopencl-2024.2.7/pytest.ini +0 -3
  62. {pyopencl-2024.2.7 → pyopencl-2024.3}/.gitignore +0 -0
  63. {pyopencl-2024.2.7 → pyopencl-2024.3}/.gitmodules +0 -0
  64. {pyopencl-2024.2.7 → pyopencl-2024.3}/.pylintrc-local.yml +0 -0
  65. {pyopencl-2024.2.7 → pyopencl-2024.3}/CITATION.cff +0 -0
  66. {pyopencl-2024.2.7 → pyopencl-2024.3}/LICENSE +0 -0
  67. {pyopencl-2024.2.7 → pyopencl-2024.3}/README.rst +0 -0
  68. {pyopencl-2024.2.7 → pyopencl-2024.3}/contrib/fortran-to-opencl/README +0 -0
  69. {pyopencl-2024.2.7 → pyopencl-2024.3}/contrib/pyopencl.vim +0 -0
  70. {pyopencl-2024.2.7 → pyopencl-2024.3}/doc/.gitignore +0 -0
  71. {pyopencl-2024.2.7 → pyopencl-2024.3}/doc/Makefile +0 -0
  72. {pyopencl-2024.2.7 → pyopencl-2024.3}/doc/algorithm.rst +0 -0
  73. {pyopencl-2024.2.7 → pyopencl-2024.3}/doc/array.rst +0 -0
  74. {pyopencl-2024.2.7 → pyopencl-2024.3}/doc/conf.py +0 -0
  75. {pyopencl-2024.2.7 → pyopencl-2024.3}/doc/howto.rst +0 -0
  76. {pyopencl-2024.2.7 → pyopencl-2024.3}/doc/index.rst +0 -0
  77. {pyopencl-2024.2.7 → pyopencl-2024.3}/doc/misc.rst +0 -0
  78. {pyopencl-2024.2.7 → pyopencl-2024.3}/doc/runtime.rst +0 -0
  79. {pyopencl-2024.2.7 → pyopencl-2024.3}/doc/runtime_const.rst +0 -0
  80. {pyopencl-2024.2.7 → pyopencl-2024.3}/doc/runtime_gl.rst +0 -0
  81. {pyopencl-2024.2.7 → pyopencl-2024.3}/doc/runtime_queue.rst +0 -0
  82. {pyopencl-2024.2.7 → pyopencl-2024.3}/doc/subst.rst +0 -0
  83. {pyopencl-2024.2.7 → pyopencl-2024.3}/doc/tools.rst +0 -0
  84. {pyopencl-2024.2.7 → pyopencl-2024.3}/doc/types.rst +0 -0
  85. {pyopencl-2024.2.7 → pyopencl-2024.3}/examples/.gitignore +0 -0
  86. {pyopencl-2024.2.7 → pyopencl-2024.3}/examples/demo-struct-reduce.py +0 -0
  87. {pyopencl-2024.2.7 → pyopencl-2024.3}/examples/demo.py +0 -0
  88. {pyopencl-2024.2.7 → pyopencl-2024.3}/examples/demo_array.py +0 -0
  89. {pyopencl-2024.2.7 → pyopencl-2024.3}/examples/demo_array_svm.py +0 -0
  90. {pyopencl-2024.2.7 → pyopencl-2024.3}/examples/demo_elementwise.py +0 -0
  91. {pyopencl-2024.2.7 → pyopencl-2024.3}/examples/demo_elementwise_complex.py +0 -0
  92. {pyopencl-2024.2.7 → pyopencl-2024.3}/examples/demo_mandelbrot.py +0 -0
  93. {pyopencl-2024.2.7 → pyopencl-2024.3}/examples/demo_meta_template.py +0 -0
  94. {pyopencl-2024.2.7 → pyopencl-2024.3}/examples/dump-performance.py +0 -0
  95. {pyopencl-2024.2.7 → pyopencl-2024.3}/examples/gl_interop_demo.py +0 -0
  96. {pyopencl-2024.2.7 → pyopencl-2024.3}/examples/gl_particle_animation.py +0 -0
  97. {pyopencl-2024.2.7 → pyopencl-2024.3}/examples/median-filter.py +0 -0
  98. {pyopencl-2024.2.7 → pyopencl-2024.3}/examples/narray.py +0 -0
  99. {pyopencl-2024.2.7 → pyopencl-2024.3}/examples/noisyImage.jpg +0 -0
  100. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/_cluda.py +0 -0
  101. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/characterize/__init__.py +0 -0
  102. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/characterize/performance.py +0 -0
  103. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/cl/pyopencl-airy.cl +0 -0
  104. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/cl/pyopencl-bessel-j-complex.cl +0 -0
  105. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/cl/pyopencl-bessel-j.cl +0 -0
  106. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/cl/pyopencl-bessel-y.cl +0 -0
  107. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/cl/pyopencl-complex.h +0 -0
  108. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/cl/pyopencl-eval-tbl.cl +0 -0
  109. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/cl/pyopencl-hankel-complex.cl +0 -0
  110. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/cl/pyopencl-random123/array.h +0 -0
  111. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/cl/pyopencl-random123/openclfeatures.h +0 -0
  112. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/cl/pyopencl-random123/philox.cl +0 -0
  113. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/cl/pyopencl-random123/threefry.cl +0 -0
  114. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/clmath.py +0 -0
  115. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/cltypes.py +0 -0
  116. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/compyte/.gitignore +0 -0
  117. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/compyte/__init__.py +0 -0
  118. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/compyte/array.py +0 -0
  119. {pyopencl-2024.2.7 → pyopencl-2024.3}/pyopencl/version.py +0 -0
  120. {pyopencl-2024.2.7 → pyopencl-2024.3}/scripts/build-ocl-macos.sh +0 -0
  121. {pyopencl-2024.2.7 → pyopencl-2024.3}/scripts/build-ocl-windows.sh +0 -0
  122. {pyopencl-2024.2.7 → pyopencl-2024.3}/scripts/build-ocl.sh +0 -0
  123. {pyopencl-2024.2.7 → pyopencl-2024.3}/src/bitlog.cpp +0 -0
  124. {pyopencl-2024.2.7 → pyopencl-2024.3}/src/bitlog.hpp +0 -0
  125. {pyopencl-2024.2.7 → pyopencl-2024.3}/src/clinfo_ext.h +0 -0
  126. {pyopencl-2024.2.7 → pyopencl-2024.3}/src/mempool.hpp +0 -0
  127. {pyopencl-2024.2.7 → pyopencl-2024.3}/src/pyopencl_ext.h +0 -0
  128. {pyopencl-2024.2.7 → pyopencl-2024.3}/src/tools.hpp +0 -0
  129. {pyopencl-2024.2.7 → pyopencl-2024.3}/src/wrap_cl.cpp +0 -0
  130. {pyopencl-2024.2.7 → pyopencl-2024.3}/src/wrap_cl_part_1.cpp +0 -0
  131. {pyopencl-2024.2.7 → pyopencl-2024.3}/src/wrap_constants.cpp +0 -0
  132. {pyopencl-2024.2.7 → pyopencl-2024.3}/src/wrap_helpers.hpp +0 -0
  133. {pyopencl-2024.2.7 → pyopencl-2024.3}/src/wrap_mempool.cpp +0 -0
  134. {pyopencl-2024.2.7 → pyopencl-2024.3}/test/add-vectors-32.spv +0 -0
  135. {pyopencl-2024.2.7 → pyopencl-2024.3}/test/add-vectors-64.spv +0 -0
  136. {pyopencl-2024.2.7 → pyopencl-2024.3}/test/empty-header.h +0 -0
@@ -1,3 +1,6 @@
1
+ variables:
2
+ GIT_SUBMODULE_STRATEGY: recursive
3
+
1
4
  Python 3 Intel CPU:
2
5
  script: |
3
6
  source /opt/enable-intel-cl.sh
@@ -165,14 +168,12 @@ Python 3 POCL (+GL and special functions):
165
168
  reports:
166
169
  junit: test/pytest.xml
167
170
 
168
- Flake8:
171
+ Ruff:
169
172
  script: |
170
- curl -L -O https://tiker.net/ci-support-v0
171
- . ci-support-v0
172
- build_py_project_in_venv
173
- install_and_run_flake8 "$(get_proj_name)" examples/*.py test/*.py
173
+ pipx install ruff
174
+ ruff check
174
175
  tags:
175
- - python3
176
+ - docker-runner
176
177
  except:
177
178
  - tags
178
179
 
@@ -241,7 +242,7 @@ Downstream:
241
242
  - DOWNSTREAM_PROJECT: [loopy, boxtree, meshmode]
242
243
  tags:
243
244
  - large-node
244
- - "docker-runner"
245
+ - docker-runner
245
246
  script: |
246
247
  curl -L -O https://tiker.net/ci-support-v0
247
248
  . ci-support-v0
@@ -10,4 +10,3 @@ dependencies:
10
10
  - ocl-icd
11
11
  - pocl
12
12
  - mako
13
- - pybind11
@@ -148,9 +148,9 @@ execute_process(
148
148
  execute_process(
149
149
  COMMAND
150
150
  "${PYTHON_EXECUTABLE}" -c "import nanobind; print(nanobind.cmake_dir())"
151
- OUTPUT_VARIABLE _tmp_dir
151
+ OUTPUT_VARIABLE NANOBIND_DIR
152
152
  OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ECHO STDOUT)
153
- list(APPEND CMAKE_PREFIX_PATH "${_tmp_dir}")
153
+ list(APPEND CMAKE_PREFIX_PATH "${NANOBIND_DIR}")
154
154
 
155
155
  # }}}
156
156
 
@@ -209,11 +209,12 @@ message("==============================")
209
209
  message("PyOpenCL ${PYOPENCL_VERSION_GIT} ${PYOPENCL_REL} configuration: ")
210
210
  message(" PyOpenCL options: PYOPENCL_TRACE=${PYOPENCL_TRACE} PYOPENCL_ENABLE_GL=${PYOPENCL_ENABLE_GL} PYOPENCL_USE_SHIPPED_EXT=${PYOPENCL_USE_SHIPPED_EXT} PYOPENCL_PRETEND_CL_VERSION=${PYOPENCL_PRETEND_CL_VERSION}")
211
211
  message(" OpenCL: ${OpenCL_LIBRARIES} [${OpenCL_VERSION_STRING}]")
212
- message(" Python: ${Python_VERSION} [${Python_EXECUTABLE}]")
212
+ message(" Python: ${Python_EXECUTABLE} [${Python_VERSION}]")
213
213
  message(" Build type: ${CMAKE_BUILD_TYPE}")
214
- message(" C++ compiler: ${CMAKE_CXX_COMPILER} [${CMAKE_CXX_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION}]")
214
+ message(" C++ compiler: ${CMAKE_CXX_COMPILER} [${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}]")
215
215
  message(" CMake: ${CMAKE_COMMAND} [${CMAKE_VERSION}]")
216
- message(" Nanobind: ${NANOBIND_VERSION}")
216
+ message(" Nanobind: ${NANOBIND_DIR} [${NANOBIND_VERSION}]")
217
+ message(" Build tool: ${CMAKE_MAKE_PROGRAM}")
217
218
  message("==============================")
218
219
 
219
220
  # }}}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyopencl
3
- Version: 2024.2.7
3
+ Version: 2024.3
4
4
  Summary: Python wrapper for OpenCL
5
5
  Author-Email: Andreas Kloeckner <inform@tiker.net>
6
6
  Classifier: Development Status :: 5 - Production/Stable
@@ -12,22 +12,25 @@ Classifier: License :: OSI Approved :: MIT License
12
12
  Classifier: Natural Language :: English
13
13
  Classifier: Programming Language :: C++
14
14
  Classifier: Programming Language :: Python
15
- Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
16
  Classifier: Topic :: Scientific/Engineering
17
17
  Classifier: Topic :: Scientific/Engineering :: Mathematics
18
18
  Classifier: Topic :: Scientific/Engineering :: Physics
19
- Project-URL: Homepage, https://mathema.tician.de/software/pyopencl
20
19
  Project-URL: Documentation, https://documen.tician.de/pyopencl
20
+ Project-URL: Homepage, https://mathema.tician.de/software/pyopencl
21
21
  Project-URL: Repository, https://github.com/inducer/pyopencl
22
22
  Requires-Python: ~=3.8
23
23
  Requires-Dist: importlib-resources; python_version < "3.9"
24
24
  Requires-Dist: numpy
25
- Requires-Dist: platformdirs>=2.2.0
25
+ Requires-Dist: platformdirs>=2.2
26
26
  Requires-Dist: pytools>=2024.1.5
27
- Requires-Dist: oclgrind_binary_distribution>=18.3; extra == "oclgrind"
28
- Requires-Dist: pocl_binary_distribution>=1.2; extra == "pocl"
29
- Requires-Dist: Mako; extra == "test"
30
- Requires-Dist: pytest>=7.0.0; extra == "test"
27
+ Requires-Dist: oclgrind-binary-distribution>=18.3; extra == "oclgrind"
28
+ Requires-Dist: pocl-binary-distribution>=1.2; extra == "pocl"
29
+ Requires-Dist: ruff; extra == "test"
30
+ Requires-Dist: mako; extra == "test"
31
+ Requires-Dist: mypy; extra == "test"
32
+ Requires-Dist: pylint; extra == "test"
33
+ Requires-Dist: pytest>=7; extra == "test"
31
34
  Provides-Extra: oclgrind
32
35
  Provides-Extra: pocl
33
36
  Provides-Extra: test
@@ -36,7 +36,7 @@ import sys
36
36
  import tempfile
37
37
 
38
38
 
39
- def main(ctx, tmp_dir, cl_str, output=None, build_options=[]):
39
+ def main(ctx, tmp_dir, cl_str, output=None, build_options=()):
40
40
  device = ctx.devices[0]
41
41
  platform = device.platform
42
42
  if platform.name == "NVIDIA CUDA":
@@ -84,8 +84,8 @@ if __name__ == "__main__":
84
84
  import pyopencl as cl
85
85
  ctx = cl.create_some_context()
86
86
  cl_file = sys.argv[1]
87
- with open(cl_file, "r") as f:
87
+ with open(cl_file) as f:
88
88
  cl_str = f.read()
89
- output = sys.argv[2] if len(sys.argv) >=3 else None
90
- build_options = sys.argv[3:] if len(sys.argv) >=4 else []
89
+ output = sys.argv[2] if len(sys.argv) >= 3 else None
90
+ build_options = sys.argv[3:] if len(sys.argv) >= 4 else []
91
91
  main(ctx, tmp_dir, cl_str, output, build_options)
@@ -22,10 +22,12 @@ THE SOFTWARE.
22
22
 
23
23
  import re
24
24
  from sys import intern
25
+ from typing import ClassVar, Dict, List, Tuple
25
26
  from warnings import warn
26
27
 
27
- import cgen
28
28
  import numpy as np
29
+
30
+ import cgen
29
31
  import pymbolic.primitives as p
30
32
  import pytools.lex
31
33
  from pymbolic.mapper import CombineMapper
@@ -132,7 +134,7 @@ def simplify_typed_literal(expr):
132
134
  class FortranExpressionParser(ExpressionParserBase):
133
135
  # FIXME double/single prec literals
134
136
 
135
- lex_table = [
137
+ lex_table: ClassVar[List[Tuple[str, str]]] = [
136
138
  (_less_than, pytools.lex.RE(r"\.lt\.", re.I)),
137
139
  (_greater_than, pytools.lex.RE(r"\.gt\.", re.I)),
138
140
  (_less_equal, pytools.lex.RE(r"\.le\.", re.I)),
@@ -143,7 +145,7 @@ class FortranExpressionParser(ExpressionParserBase):
143
145
  (_not, pytools.lex.RE(r"\.not\.", re.I)),
144
146
  (_and, pytools.lex.RE(r"\.and\.", re.I)),
145
147
  (_or, pytools.lex.RE(r"\.or\.", re.I)),
146
- ] + ExpressionParserBase.lex_table
148
+ *ExpressionParserBase.lex_table]
147
149
 
148
150
  def __init__(self, tree_walker):
149
151
  self.tree_walker = tree_walker
@@ -209,7 +211,7 @@ class FortranExpressionParser(ExpressionParserBase):
209
211
  return ExpressionParserBase.parse_terminal(
210
212
  self, pstate)
211
213
 
212
- COMP_MAP = {
214
+ COMP_MAP: ClassVar[Dict[str, str]] = {
213
215
  _less_than: "<",
214
216
  _less_equal: "<=",
215
217
  _greater_than: ">",
@@ -233,8 +235,12 @@ class FortranExpressionParser(ExpressionParserBase):
233
235
 
234
236
  def parse_postfix(self, pstate, min_precedence, left_exp):
235
237
  from pymbolic.parser import (
236
- _PREC_CALL, _PREC_COMPARISON, _PREC_LOGICAL_AND, _PREC_LOGICAL_OR,
237
- _openpar)
238
+ _PREC_CALL,
239
+ _PREC_COMPARISON,
240
+ _PREC_LOGICAL_AND,
241
+ _PREC_LOGICAL_OR,
242
+ _openpar,
243
+ )
238
244
  from pymbolic.primitives import Comparison, LogicalAnd, LogicalOr
239
245
 
240
246
  next_tag = pstate.next_tag()
@@ -941,7 +947,7 @@ class F2CLTranslator(FTreeWalkerBase):
941
947
 
942
948
  if shape is not None:
943
949
  dim_stmt = cgen.Statement(
944
- 'dimension \"fortran\" {}[{}]'.format(
950
+ 'dimension "fortran" {}[{}]'.format(
945
951
  scope.translate_var_name(name),
946
952
  ", ".join(gen_shape(s) for s in shape)
947
953
  ))
@@ -1017,7 +1023,7 @@ class F2CLTranslator(FTreeWalkerBase):
1017
1023
  body = self.map_statement_list(node.content)
1018
1024
 
1019
1025
  pre_func_decl, in_func_decl = self.get_declarations()
1020
- body = in_func_decl + [cgen.Line()] + body
1026
+ body = [*in_func_decl, cgen.Line(), *body]
1021
1027
 
1022
1028
  if isinstance(body[-1], cgen.Statement) and body[-1].text == "return":
1023
1029
  body.pop()
@@ -1046,7 +1052,7 @@ class F2CLTranslator(FTreeWalkerBase):
1046
1052
 
1047
1053
  self.scope_stack.pop()
1048
1054
  if pre_func_decl:
1049
- return pre_func_decl + [cgen.Line(), result]
1055
+ return [*pre_func_decl, cgen.Line(), result]
1050
1056
  else:
1051
1057
  return result
1052
1058
 
@@ -1073,7 +1079,7 @@ class F2CLTranslator(FTreeWalkerBase):
1073
1079
  def map_Equivalence(self, node):
1074
1080
  raise NotImplementedError("equivalence")
1075
1081
 
1076
- TYPE_MAP = {
1082
+ TYPE_MAP: ClassVar[Dict[Tuple[str, str], np.generic]] = {
1077
1083
  ("real", "4"): np.float32,
1078
1084
  ("real", "8"): np.float64,
1079
1085
  ("real", "16"): np.float128,
@@ -1090,7 +1096,7 @@ class F2CLTranslator(FTreeWalkerBase):
1090
1096
  def dtype_from_stmt(self, stmt):
1091
1097
  length, kind = stmt.selector
1092
1098
  assert not kind
1093
- return np.dtype(self.TYPE_MAP[(type(stmt).__name__.lower(), length)])
1099
+ return np.dtype(self.TYPE_MAP[type(stmt).__name__.lower(), length])
1094
1100
 
1095
1101
  def map_type_decl(self, node):
1096
1102
  scope = self.scope_stack[-1]
@@ -1198,8 +1204,8 @@ class F2CLTranslator(FTreeWalkerBase):
1198
1204
  raise NotImplementedError("save")
1199
1205
 
1200
1206
  def map_Line(self, node):
1201
- #from warnings import warn
1202
- #warn("Encountered a 'line': %s" % node)
1207
+ # from warnings import warn
1208
+ # warn("Encountered a 'line': %s" % node)
1203
1209
  raise NotImplementedError
1204
1210
 
1205
1211
  def map_Program(self, node):
@@ -1382,9 +1388,9 @@ def f2cl(source, free_form=False, strict=True,
1382
1388
  if isinstance(entry, cgen.FunctionBody):
1383
1389
  func_decls.append(entry.fdecl)
1384
1390
 
1385
- mod = cgen.Module(func_decls + [cgen.Line()] + source)
1391
+ mod = cgen.Module([*func_decls, cgen.Line(), *source])
1386
1392
 
1387
- #open("pre-cnd.cl", "w").write(str(mod))
1393
+ # open("pre-cnd.cl", "w").write(str(mod))
1388
1394
 
1389
1395
  from cnd import transform_cl
1390
1396
  str_mod = transform_cl(str(mod))
@@ -507,7 +507,7 @@ else:
507
507
  }
508
508
 
509
509
  cls_ext_lookup = {
510
- #cl.buffer_create_type: ("CL_1.1", "0.92"),
510
+ # cl.buffer_create_type: ("CL_1.1", "0.92"),
511
511
  }
512
512
 
513
513
 
@@ -281,36 +281,11 @@ Image
281
281
  See :class:`mem_flags` for possible values of *flags*
282
282
  and :class:`mem_object_type` for possible values of *image_type*.
283
283
 
284
- .. class:: Image(context, flags, format, shape=None, pitches=None, hostbuf=None, is_array=False, buffer=None)
285
-
286
- See :class:`mem_flags` for values of *flags*.
287
- *shape* is a 2- or 3-tuple. *format* is an instance of :class:`ImageFormat`.
288
- *pitches* is a 1-tuple for 2D images and a 2-tuple for 3D images, indicating
289
- the distance in bytes from one scan line to the next, and from one 2D image
290
- slice to the next.
291
-
292
- If *hostbuf* is given and *shape* is *None*, then *hostbuf.shape* is
293
- used as the *shape* parameter.
294
-
295
- :class:`Image` inherits from :class:`MemoryObject`.
296
-
297
- .. note::
298
-
299
- If you want to load images from :class:`numpy.ndarray` instances or read images
300
- back into them, be aware that OpenCL images expect the *x* dimension to vary
301
- fastest, whereas in the default (C) order of :mod:`numpy` arrays, the last index
302
- varies fastest. If your array is arranged in the wrong order in memory,
303
- there are two possible fixes for this:
304
-
305
- * Convert the array to Fortran (column-major) order using :func:`numpy.asarray`.
306
-
307
- * Pass *ary.T.copy()* to the image creation function.
284
+ .. class:: Image
285
+ Use :func:`create_image` to create images.
308
286
 
309
287
  .. versionadded:: 0.91
310
288
 
311
- .. versionchanged:: 2011.2
312
- Added *is_array* and *buffer*, which are only available on CL 1.2 and newer.
313
-
314
289
  .. attribute:: info
315
290
 
316
291
  Lower case versions of the :class:`mem_info`
@@ -330,6 +305,8 @@ Image
330
305
 
331
306
  |comparable|
332
307
 
308
+ .. autofunction:: create_image
309
+
333
310
  .. function:: image_from_array(ctx, ary, num_channels=None, mode="r", norm_int=False)
334
311
 
335
312
  Build a 2D or 3D :class:`Image` from the :class:`numpy.ndarray` *ary*. If
@@ -525,3 +502,7 @@ Type aliases
525
502
  .. class:: Buffer
526
503
 
527
504
  See :class:`pyopencl.Buffer`.
505
+
506
+ .. class:: Image
507
+
508
+ See :class:`pyopencl.Image`.
@@ -109,7 +109,7 @@ Device
109
109
  Context
110
110
  -------
111
111
 
112
- .. class:: Context(devices=None, properties=None, dev_type=None, cache_dir=None)
112
+ .. class:: Context(devices=None, properties=None, dev_type=None)
113
113
 
114
114
  Create a new context. *properties* is a list of key-value
115
115
  tuples, where each key must be one of :class:`context_properties`.
@@ -119,17 +119,22 @@ Context
119
119
  If neither is specified, a context with a *dev_type* of
120
120
  :attr:`device_type.DEFAULT` is created.
121
121
 
122
- If *cache_dir* is not *None* - it will be used as default *cache_dir*
123
- for all its' :class:`Program` instances builds (see also :meth:`Program.build`).
124
-
125
122
  .. note::
126
123
 
127
- Calling the constructor with no arguments will fail for
124
+ Calling the constructor with no arguments may fail for
128
125
  CL drivers that support the OpenCL ICD (which applies to most modern systems).
129
126
  If you want similar, just-give-me-a-context-already behavior, we recommend
130
- :func:`create_some_context`. See, e.g. this
127
+ :func:`create_some_context`.
128
+
129
+ See e.g. this
131
130
  `explanation by AMD
132
- <https://web.archive.org/web/20101114195033/https://developer.amd.com/support/KnowledgeBase/Lists/KnowledgeBase/DispForm.aspx?ID=71>`__.
131
+ <https://web.archive.org/web/20101114195033/https://developer.amd.com/support/KnowledgeBase/Lists/KnowledgeBase/DispForm.aspx?ID=71>`__:
132
+
133
+ **What has changed?**
134
+
135
+ In previous beta releases functions such as clGetDeviceIDs() and clCreateContext()
136
+ accepted a NULL value for the platform parameter. This release no longer
137
+ allows this - the platform must be a valid one obtained by using the platform API.
133
138
 
134
139
  .. note::
135
140
 
@@ -129,6 +129,14 @@ Program
129
129
  in the same name space and take precedence over
130
130
  :class:`Kernel` names.
131
131
 
132
+ .. note::
133
+
134
+ If you need to retrieve a kernel whose name includes non-identifier
135
+ characters, retrieving it as an attribute of
136
+ :class:`~pyopencl.Program` will
137
+ not work, for obvious reasons. In that case, you can use
138
+ the :class:`~pyopencl.Kernel` constructor directly.
139
+
132
140
  .. method:: all_kernels()
133
141
 
134
142
  Returns a list of all :class:`Kernel` objects in the :class:`Program`.
@@ -2025,7 +2025,7 @@ if __name__ == "__main__":
2025
2025
  # Tracksave of trajectories
2026
2026
  TrackSave = False
2027
2027
 
2028
- HowToUse = "%s -h [Help] -b [BlackBodyEmission] -j [TrackSave] -n [NoImage] -p <Einstein/Newton> -s <SizeInPixels> -m <Mass> -i <DiscInternalRadius> -x <DiscExternalRadius> -a <AngleAboveDisc> -d <DeviceId> -c <Greyscale/Red2Yellow> -g <CUDA/OpenCL> -o <EachPixel/TrajectoCircle/TrajectoPixel/EachCircle/Original> -t <ThreadsInCuda> -v <FP32/FP64> -k <TrackPoints>" # noqa: E501
2028
+ HowToUse = "%s -h [Help] -b [BlackBodyEmission] -j [TrackSave] -n [NoImage] -p <Einstein/Newton> -s <SizeInPixels> -m <Mass> -i <DiscInternalRadius> -x <DiscExternalRadius> -a <AngleAboveDisc> -d <DeviceId> -c <Greyscale/Red2Yellow> -g <CUDA/OpenCL> -o <EachPixel/TrajectoCircle/TrajectoPixel/EachCircle/Original> -t <ThreadsInCuda> -v <FP32/FP64> -k <TrackPoints>"
2029
2029
 
2030
2030
  try:
2031
2031
  opts, args = getopt.getopt(
@@ -1,8 +1,18 @@
1
1
  import numpy as np
2
2
  import numpy.linalg as la
3
+
3
4
  from cgen import (
4
- POD, Assign, Block, Const, FunctionBody, FunctionDeclaration, Initializer,
5
- Module, Pointer, Value)
5
+ POD,
6
+ Assign,
7
+ Block,
8
+ Const,
9
+ FunctionBody,
10
+ FunctionDeclaration,
11
+ Initializer,
12
+ Module,
13
+ Pointer,
14
+ Value,
15
+ )
6
16
  from cgen.opencl import CLGlobal, CLKernel, CLRequiredWorkGroupSize
7
17
 
8
18
  import pyopencl as cl
@@ -49,8 +49,8 @@ for platform in cl.get_platforms():
49
49
  ctx = cl.Context([device])
50
50
  for mf in [
51
51
  cl.mem_flags.READ_ONLY,
52
- #cl.mem_flags.READ_WRITE,
53
- #cl.mem_flags.WRITE_ONLY
52
+ # cl.mem_flags.READ_WRITE,
53
+ # cl.mem_flags.WRITE_ONLY
54
54
  ]:
55
55
  for itype in [
56
56
  cl.mem_object_type.IMAGE2D,
@@ -12,8 +12,8 @@
12
12
  },
13
13
  "outputs": [],
14
14
  "source": [
15
- "from __future__ import division\n",
16
15
  "import numpy as np\n",
16
+ "\n",
17
17
  "import pyopencl as cl\n",
18
18
  "import pyopencl.array"
19
19
  ]
@@ -126,7 +126,8 @@
126
126
  "a = cl.array.empty(queue, n, dtype=np.float32)\n",
127
127
  "a.fill(15)\n",
128
128
  "\n",
129
- "b_host = np.random.randn(n).astype(np.float32)\n",
129
+ "rng = np.random.default_rng()\n",
130
+ "b_host = rng.normal(size=n).astype(np.float32)\n",
130
131
  "b = cl.array.to_device(queue, b_host)\n",
131
132
  "\n",
132
133
  "c = cl.array.empty_like(a)"
@@ -152,7 +153,7 @@
152
153
  },
153
154
  "outputs": [],
154
155
  "source": [
155
- "sum_vector(queue, (n,), None, a.data, b.data, c.data)"
156
+ "sum_vector(queue, (n,), None, a.data, b.data, c.data) # noqa: F821"
156
157
  ]
157
158
  },
158
159
  {
@@ -195,7 +196,7 @@
195
196
  "name": "python",
196
197
  "nbconvert_exporter": "python",
197
198
  "pygments_lexer": "ipython3",
198
- "version": "3.10.5"
199
+ "version": "3.12.4"
199
200
  }
200
201
  },
201
202
  "nbformat": 4,
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
2
+
3
3
  """
4
4
  NBody Demonstrator implemented in OpenCL, rendering OpenGL
5
5
 
@@ -676,7 +676,7 @@ if __name__ == "__main__":
676
676
  # Type of Interaction
677
677
  InterType = "Force"
678
678
 
679
- HowToUse = "%s -h [Help] -r [InitialRandom] -g [OpenGL] -e [VirielStress] -o [Verbose] -p [Potential] -x <None|NegExp|CorRad> -d <DeviceId> -n <NumberOfParticules> -i <Iterations> -z <SizeOfBoxOrBall> -v <Velocity> -s <Step> -b <Ball|Box> -m <ImplicitEuler|RungeKutta|ExplicitEuler|Heun> -t <FP32|FP64>" # noqa: E501
679
+ HowToUse = "%s -h [Help] -r [InitialRandom] -g [OpenGL] -e [VirielStress] -o [Verbose] -p [Potential] -x <None|NegExp|CorRad> -d <DeviceId> -n <NumberOfParticules> -i <Iterations> -z <SizeOfBoxOrBall> -v <Velocity> -s <Step> -b <Ball|Box> -m <ImplicitEuler|RungeKutta|ExplicitEuler|Heun> -t <FP32|FP64>"
680
680
 
681
681
  try:
682
682
  opts, args = getopt.getopt(
@@ -833,8 +833,8 @@ if __name__ == "__main__":
833
833
 
834
834
  # Build all routines used for the computing
835
835
 
836
- # BuildOptions="-cl-mad-enable -cl-kernel-arg-info -cl-fast-relaxed-math -cl-std=CL1.2 -DTRNG=%i -DTYPE=%i" % (Marsaglia[RNG],Computing[ValueType]) # noqa: E501
837
- BuildOptions = "-cl-mad-enable -cl-fast-relaxed-math -DTRNG=%i -DTYPE=%i -DINTERACTION=%i -DARTEVASION=%i" % ( # noqa: E501
836
+ # BuildOptions="-cl-mad-enable -cl-kernel-arg-info -cl-fast-relaxed-math -cl-std=CL1.2 -DTRNG=%i -DTYPE=%i" % (Marsaglia[RNG],Computing[ValueType])
837
+ BuildOptions = "-cl-mad-enable -cl-fast-relaxed-math -DTRNG=%i -DTYPE=%i -DINTERACTION=%i -DARTEVASION=%i" % (
838
838
  Marsaglia[RNG],
839
839
  Computing[ValueType],
840
840
  Interaction[InterType],
@@ -864,7 +864,7 @@ if __name__ == "__main__":
864
864
  # Write/HostPointer approach for buffering
865
865
  # clDataX = cl.Buffer(ctx, mf.WRITE_ONLY|mf.COPY_HOST_PTR,hostbuf=MyDataX)
866
866
  # clDataV = cl.Buffer(ctx, mf.WRITE_ONLY|mf.COPY_HOST_PTR,hostbuf=MyDataV)
867
- # clPotential = cl.Buffer(ctx, mf.WRITE_ONLY|mf.COPY_HOST_PTR,hostbuf=MyPotential) # noqa: E501
867
+ # clPotential = cl.Buffer(ctx, mf.WRITE_ONLY|mf.COPY_HOST_PTR,hostbuf=MyPotential)
868
868
  # clKinetic = cl.Buffer(ctx, mf.WRITE_ONLY|mf.COPY_HOST_PTR,hostbuf=MyKinetic)
869
869
  # clCoM = cl.Buffer(ctx, mf.WRITE_ONLY|mf.COPY_HOST_PTR,hostbuf=MyCoM)
870
870
 
@@ -1011,7 +1011,7 @@ if __name__ == "__main__":
1011
1011
  )
1012
1012
 
1013
1013
  print(
1014
- "Duration stats on device %s with %s iterations :\n\tMean:\t%s\n\tMedian:\t%s\n\tStddev:\t%s\n\tMin:\t%s\n\tMax:\t%s\n\n\tVariability:\t%s\n" # noqa: E501
1014
+ "Duration stats on device %s with %s iterations :\n\tMean:\t%s\n\tMedian:\t%s\n\tStddev:\t%s\n\tMin:\t%s\n\tMax:\t%s\n\n\tVariability:\t%s\n"
1015
1015
  % (
1016
1016
  Device,
1017
1017
  Iterations,
@@ -1029,7 +1029,7 @@ if __name__ == "__main__":
1029
1029
  FPS /= Durations
1030
1030
 
1031
1031
  print(
1032
- "FPS stats on device %s with %s iterations :\n\tMean:\t%s\n\tMedian:\t%s\n\tStddev:\t%s\n\tMin:\t%s\n\tMax:\t%s\n" # noqa: E501
1032
+ "FPS stats on device %s with %s iterations :\n\tMean:\t%s\n\tMedian:\t%s\n\tStddev:\t%s\n\tMin:\t%s\n\tMax:\t%s\n"
1033
1033
  % (
1034
1034
  Device,
1035
1035
  Iterations,
@@ -1047,7 +1047,7 @@ if __name__ == "__main__":
1047
1047
  Squertz /= Durations
1048
1048
 
1049
1049
  print(
1050
- "Squertz in log10 & complete stats on device %s with %s iterations :\n\tMean:\t%s\t%s\n\tMedian:\t%s\t%s\n\tStddev:\t%s\t%s\n\tMin:\t%s\t%s\n\tMax:\t%s\t%s\n" # noqa: E501
1050
+ "Squertz in log10 & complete stats on device %s with %s iterations :\n\tMean:\t%s\t%s\n\tMedian:\t%s\t%s\n\tStddev:\t%s\t%s\n\tMin:\t%s\t%s\n\tMax:\t%s\t%s\n"
1051
1051
  % (
1052
1052
  Device,
1053
1053
  Iterations,
@@ -492,8 +492,8 @@ def MetropolisCuda(InputCU):
492
492
  except Exception:
493
493
  print("Compilation seems to break")
494
494
 
495
- MetropolisBlocksCU = mod.get_function("MainLoopBlocks") # noqa: F841
496
- MetropolisThreadsCU = mod.get_function("MainLoopThreads") # noqa: F841
495
+ MetropolisBlocksCU = mod.get_function("MainLoopBlocks")
496
+ MetropolisThreadsCU = mod.get_function("MainLoopThreads")
497
497
  MetropolisHybridCU = mod.get_function("MainLoopHybrid")
498
498
 
499
499
  MyDuration = numpy.zeros(steps)
@@ -1163,4 +1163,5 @@ if __name__ == "__main__":
1163
1163
  )
1164
1164
 
1165
1165
  if Fit:
1166
- FitAndPrint(ExploredJobs, median, Curves) # noqa: F821, E501 # FIXME: undefined var 'median'
1166
+ # FIXME: undefined var 'median'
1167
+ FitAndPrint(ExploredJobs, median, Curves) # noqa: F821
@@ -4,8 +4,10 @@ import numpy as np
4
4
 
5
5
  import pyopencl as cl
6
6
  from pyopencl.characterize import (
7
- has_coarse_grain_buffer_svm, has_fine_grain_buffer_svm,
8
- has_fine_grain_system_svm)
7
+ has_coarse_grain_buffer_svm,
8
+ has_fine_grain_buffer_svm,
9
+ has_fine_grain_system_svm,
10
+ )
9
11
 
10
12
 
11
13
  ctx = cl.create_some_context()
@@ -204,8 +204,7 @@ def benchmark_transpose():
204
204
  a_t_buf.release()
205
205
 
206
206
  try:
207
- from matplotlib.pyplot import (
208
- clf, grid, legend, plot, savefig, xlabel, ylabel)
207
+ from matplotlib.pyplot import clf, grid, legend, plot, savefig, xlabel, ylabel
209
208
  except ModuleNotFoundError:
210
209
  pass
211
210
  else: