pyopencl 2024.2.2__cp310-cp310-win_amd64.whl → 2024.2.4__cp310-cp310-win_amd64.whl

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 (102) hide show
  1. pyopencl/__init__.py +16 -4
  2. pyopencl/_cl.cp310-win_amd64.pyd +0 -0
  3. pyopencl/algorithm.py +3 -1
  4. pyopencl/bitonic_sort.py +2 -0
  5. pyopencl/characterize/__init__.py +23 -0
  6. pyopencl/compyte/.git +1 -0
  7. pyopencl/compyte/.github/workflows/autopush.yml +21 -0
  8. pyopencl/compyte/.github/workflows/ci.yml +30 -0
  9. pyopencl/compyte/.gitignore +21 -0
  10. pyopencl/compyte/ndarray/Makefile +31 -0
  11. pyopencl/compyte/ndarray/gpu_ndarray.h +35 -0
  12. pyopencl/compyte/ndarray/pygpu_language.h +207 -0
  13. pyopencl/compyte/ndarray/pygpu_language_cuda.cu +622 -0
  14. pyopencl/compyte/ndarray/pygpu_language_opencl.cpp +317 -0
  15. pyopencl/compyte/ndarray/pygpu_ndarray.cpp +1546 -0
  16. pyopencl/compyte/ndarray/pygpu_ndarray.h +71 -0
  17. pyopencl/compyte/ndarray/pygpu_ndarray_object.h +232 -0
  18. pyopencl/compyte/setup.cfg +9 -0
  19. pyopencl/tools.py +60 -56
  20. pyopencl/version.py +7 -3
  21. {pyopencl-2024.2.2.dist-info → pyopencl-2024.2.4.dist-info}/METADATA +105 -105
  22. pyopencl-2024.2.4.dist-info/RECORD +59 -0
  23. {pyopencl-2024.2.2.dist-info → pyopencl-2024.2.4.dist-info}/WHEEL +1 -1
  24. pyopencl-2024.2.2.data/data/CITATION.cff +0 -74
  25. pyopencl-2024.2.2.data/data/CMakeLists.txt +0 -83
  26. pyopencl-2024.2.2.data/data/Makefile.in +0 -21
  27. pyopencl-2024.2.2.data/data/README.rst +0 -70
  28. pyopencl-2024.2.2.data/data/README_SETUP.txt +0 -34
  29. pyopencl-2024.2.2.data/data/aksetup_helper.py +0 -1013
  30. pyopencl-2024.2.2.data/data/configure.py +0 -6
  31. pyopencl-2024.2.2.data/data/contrib/cldis.py +0 -91
  32. pyopencl-2024.2.2.data/data/contrib/fortran-to-opencl/README +0 -29
  33. pyopencl-2024.2.2.data/data/contrib/fortran-to-opencl/translate.py +0 -1441
  34. pyopencl-2024.2.2.data/data/contrib/pyopencl.vim +0 -84
  35. pyopencl-2024.2.2.data/data/doc/Makefile +0 -23
  36. pyopencl-2024.2.2.data/data/doc/algorithm.rst +0 -214
  37. pyopencl-2024.2.2.data/data/doc/array.rst +0 -305
  38. pyopencl-2024.2.2.data/data/doc/conf.py +0 -26
  39. pyopencl-2024.2.2.data/data/doc/howto.rst +0 -105
  40. pyopencl-2024.2.2.data/data/doc/index.rst +0 -137
  41. pyopencl-2024.2.2.data/data/doc/make_constants.py +0 -561
  42. pyopencl-2024.2.2.data/data/doc/misc.rst +0 -885
  43. pyopencl-2024.2.2.data/data/doc/runtime.rst +0 -51
  44. pyopencl-2024.2.2.data/data/doc/runtime_const.rst +0 -30
  45. pyopencl-2024.2.2.data/data/doc/runtime_gl.rst +0 -78
  46. pyopencl-2024.2.2.data/data/doc/runtime_memory.rst +0 -527
  47. pyopencl-2024.2.2.data/data/doc/runtime_platform.rst +0 -184
  48. pyopencl-2024.2.2.data/data/doc/runtime_program.rst +0 -364
  49. pyopencl-2024.2.2.data/data/doc/runtime_queue.rst +0 -182
  50. pyopencl-2024.2.2.data/data/doc/subst.rst +0 -36
  51. pyopencl-2024.2.2.data/data/doc/tools.rst +0 -4
  52. pyopencl-2024.2.2.data/data/doc/types.rst +0 -42
  53. pyopencl-2024.2.2.data/data/examples/black-hole-accretion.py +0 -2227
  54. pyopencl-2024.2.2.data/data/examples/demo-struct-reduce.py +0 -75
  55. pyopencl-2024.2.2.data/data/examples/demo.py +0 -39
  56. pyopencl-2024.2.2.data/data/examples/demo_array.py +0 -32
  57. pyopencl-2024.2.2.data/data/examples/demo_array_svm.py +0 -37
  58. pyopencl-2024.2.2.data/data/examples/demo_elementwise.py +0 -34
  59. pyopencl-2024.2.2.data/data/examples/demo_elementwise_complex.py +0 -53
  60. pyopencl-2024.2.2.data/data/examples/demo_mandelbrot.py +0 -183
  61. pyopencl-2024.2.2.data/data/examples/demo_meta_codepy.py +0 -56
  62. pyopencl-2024.2.2.data/data/examples/demo_meta_template.py +0 -55
  63. pyopencl-2024.2.2.data/data/examples/dump-performance.py +0 -38
  64. pyopencl-2024.2.2.data/data/examples/dump-properties.py +0 -86
  65. pyopencl-2024.2.2.data/data/examples/gl_interop_demo.py +0 -84
  66. pyopencl-2024.2.2.data/data/examples/gl_particle_animation.py +0 -218
  67. pyopencl-2024.2.2.data/data/examples/ipython-demo.ipynb +0 -203
  68. pyopencl-2024.2.2.data/data/examples/median-filter.py +0 -99
  69. pyopencl-2024.2.2.data/data/examples/n-body.py +0 -1070
  70. pyopencl-2024.2.2.data/data/examples/narray.py +0 -37
  71. pyopencl-2024.2.2.data/data/examples/noisyImage.jpg +0 -0
  72. pyopencl-2024.2.2.data/data/examples/pi-monte-carlo.py +0 -1166
  73. pyopencl-2024.2.2.data/data/examples/svm.py +0 -82
  74. pyopencl-2024.2.2.data/data/examples/transpose.py +0 -229
  75. pyopencl-2024.2.2.data/data/pytest.ini +0 -3
  76. pyopencl-2024.2.2.data/data/src/bitlog.cpp +0 -51
  77. pyopencl-2024.2.2.data/data/src/bitlog.hpp +0 -83
  78. pyopencl-2024.2.2.data/data/src/clinfo_ext.h +0 -134
  79. pyopencl-2024.2.2.data/data/src/mempool.hpp +0 -444
  80. pyopencl-2024.2.2.data/data/src/pyopencl_ext.h +0 -77
  81. pyopencl-2024.2.2.data/data/src/tools.hpp +0 -90
  82. pyopencl-2024.2.2.data/data/src/wrap_cl.cpp +0 -61
  83. pyopencl-2024.2.2.data/data/src/wrap_cl.hpp +0 -5853
  84. pyopencl-2024.2.2.data/data/src/wrap_cl_part_1.cpp +0 -369
  85. pyopencl-2024.2.2.data/data/src/wrap_cl_part_2.cpp +0 -702
  86. pyopencl-2024.2.2.data/data/src/wrap_constants.cpp +0 -1274
  87. pyopencl-2024.2.2.data/data/src/wrap_helpers.hpp +0 -213
  88. pyopencl-2024.2.2.data/data/src/wrap_mempool.cpp +0 -738
  89. pyopencl-2024.2.2.data/data/test/add-vectors-32.spv +0 -0
  90. pyopencl-2024.2.2.data/data/test/add-vectors-64.spv +0 -0
  91. pyopencl-2024.2.2.data/data/test/empty-header.h +0 -1
  92. pyopencl-2024.2.2.data/data/test/test_algorithm.py +0 -1180
  93. pyopencl-2024.2.2.data/data/test/test_array.py +0 -2392
  94. pyopencl-2024.2.2.data/data/test/test_arrays_in_structs.py +0 -100
  95. pyopencl-2024.2.2.data/data/test/test_clmath.py +0 -529
  96. pyopencl-2024.2.2.data/data/test/test_clrandom.py +0 -75
  97. pyopencl-2024.2.2.data/data/test/test_enqueue_copy.py +0 -271
  98. pyopencl-2024.2.2.data/data/test/test_wrapper.py +0 -1565
  99. pyopencl-2024.2.2.dist-info/LICENSE +0 -282
  100. pyopencl-2024.2.2.dist-info/RECORD +0 -123
  101. pyopencl-2024.2.2.dist-info/top_level.txt +0 -1
  102. {pyopencl-2024.2.2.data/data → pyopencl-2024.2.4.dist-info/licenses}/LICENSE +0 -0
@@ -0,0 +1,317 @@
1
+ #include <sys/types.h>
2
+ #include <assert.h>
3
+ #include <stdio.h>
4
+
5
+ #include <pygpu_ndarray_object.h>
6
+ #include <pygpu_language.h>
7
+
8
+ #ifdef __APPLE__
9
+
10
+ #include <OpenCL/opencl.h>
11
+
12
+ #else
13
+
14
+ #include <CL/opencl.h>
15
+
16
+ #endif
17
+
18
+ cl_context ctx = NULL;
19
+ cl_device_id dev;
20
+ cl_command_queue q;
21
+
22
+ void setup_context(cl_context c);
23
+
24
+ static void
25
+ init_context(void)
26
+ {
27
+ cl_int err;
28
+ cl_uint n;
29
+ cl_platform_id *plats;
30
+ cl_context_properties props[3];
31
+ cl_context c;
32
+
33
+ if (ctx != NULL) return;
34
+
35
+ err = clGetPlatformIDs(0, NULL, &n);
36
+ if (err != CL_SUCCESS) return;
37
+
38
+ plats = (cl_platform_id *)calloc(n, sizeof(cl_platform_id));
39
+ if (plats == NULL) return;
40
+
41
+ err = clGetPlatformIDs(n, plats, NULL);
42
+ if (err != CL_SUCCESS) goto fail_id;
43
+
44
+ props[0] = CL_CONTEXT_PLATFORM;
45
+ props[1] = (cl_context_properties)plats[0];
46
+ props[2] = 0;
47
+
48
+ c = clCreateContextFromType(props, CL_DEVICE_TYPE_GPU, NULL, NULL, &err);
49
+ if (err != CL_SUCCESS) {
50
+ fprintf(stderr, "Could not create context, will fail later (%d)!\n", err);
51
+ /* error - error - error */
52
+ /* but we do nothing */
53
+ goto fail_id;
54
+ }
55
+
56
+ free(plats);
57
+
58
+ setup_context(c);
59
+ clReleaseContext(c);
60
+
61
+ return;
62
+ fail_id:
63
+ free(plats);
64
+ }
65
+
66
+ void
67
+ setup_context(cl_context c) {
68
+ cl_int err;
69
+ cl_device_id *devs;
70
+ size_t sz;
71
+
72
+ if (ctx != NULL) {
73
+ clReleaseContext(ctx);
74
+ clReleaseCommandQueue(q);
75
+ }
76
+ ctx = c;
77
+ clRetainContext(ctx);
78
+
79
+ err = clGetContextInfo(ctx, CL_CONTEXT_DEVICES, 0, NULL, &sz);
80
+ if (err != CL_SUCCESS) {
81
+ fprintf(stderr, "clGetContextInfo = %d\n", err);
82
+ goto fail;
83
+ }
84
+
85
+ devs = (cl_device_id *)malloc(sz);
86
+ if (devs == NULL) goto fail;
87
+
88
+ err = clGetContextInfo(ctx, CL_CONTEXT_DEVICES, sz, devs, NULL);
89
+ if (err != CL_SUCCESS) goto fail_dev;
90
+
91
+ dev = devs[0];
92
+ free(devs);
93
+
94
+ q = clCreateCommandQueue(ctx, dev, NULL, &err);
95
+ if (err != CL_SUCCESS) {
96
+ fprintf(stderr, "clCreateCommandQueue = %d", err);
97
+ goto fail;
98
+ }
99
+
100
+ return;
101
+ fail_dev:
102
+ free(devs);
103
+ fail:
104
+ clReleaseContext(ctx);
105
+ ctx = NULL;
106
+ }
107
+
108
+ void *
109
+ device_malloc(size_t size)
110
+ {
111
+ cl_int err;
112
+ cl_mem res;
113
+
114
+ init_context();
115
+
116
+ DPRINTF("malloc size = %zu\n", size);
117
+
118
+ /* OpenCL devices do not always support byte-addressable storage
119
+ therefore make sure we have at least 4 bytes in buffers */
120
+ if (size < 4) size = 4;
121
+
122
+ res = clCreateBuffer(ctx, CL_MEM_READ_WRITE, size, NULL, &err);
123
+ if (err != CL_SUCCESS) {
124
+ PyErr_Format(PyExc_MemoryError, "Could not allocate device memory (%d)", err);
125
+ return NULL;
126
+ }
127
+
128
+ return res;
129
+ }
130
+
131
+ int
132
+ device_free(void * ptr)
133
+ {
134
+ cl_int err;
135
+
136
+ if ((err = clReleaseMemObject((cl_mem)ptr)) != CL_SUCCESS) {
137
+ PyErr_Format(PyExc_MemoryError, "Could not free device memory (%d)", err);
138
+ return -1;
139
+ }
140
+ return 0;
141
+ }
142
+
143
+ int
144
+ PyGpuNdArray_CopyFromPyGpuNdArray(PyGpuNdArrayObject * self,
145
+ PyGpuNdArrayObject * other,
146
+ bool unbroadcast)
147
+ {
148
+ size_t size = 1;
149
+ cl_event ev;
150
+ cl_int err;
151
+
152
+ assert(PyGpuNdArray_TYPE(self) == PyGpuNdArray_TYPE(other));
153
+ assert(PyGpuNdArray_ISWRITEABLE(self));
154
+ if (PyGpuNdArray_NDIM(self) == -1) {
155
+ PyErr_SetString(PyExc_TypeError, "can't copy into un-initialized PyGpuN\
156
+ dArrayObject");
157
+ return -1;
158
+ }
159
+
160
+ if (!(PyGpuNdArray_ISONESEGMENT(self) && PyGpuNdArray_ISONESEGMENT(other))) {
161
+ PyErr_Format(PyExc_NotImplementedError, "PyGpuNdArray_CopyFromPyGpuNdArray: only contiguous arrays are supported");
162
+ return -1;
163
+ }
164
+
165
+ if ((PyGpuNdArray_ISCONTIGUOUS(self) != PyGpuNdArray_ISCONTIGUOUS(other)) ||
166
+ (PyGpuNdArray_ISFORTRAN(self) != PyGpuNdArray_ISFORTRAN(other))
167
+ ) {
168
+ PyErr_Format(PyExc_NotImplementedError, "PyGpuNdArray_CopyFromPyGpuNdArray: the input and output don't have the same c/f contiguous memory layout. This isnot supported now.");
169
+ return -1;
170
+ }
171
+
172
+ if (PyGpuNdArray_NDIM(self) != PyGpuNdArray_NDIM(other)) {
173
+ PyErr_Format(PyExc_NotImplementedError, "PyGpuNdArray_CopyFromPyGpuNdArray: need same number of dims. destination nd=%d, source nd=%d. No broadcasting implemented.", PyGpuNdArray_NDIM(self), PyGpuNdArray_NDIM(other));
174
+ return -1;
175
+ }
176
+
177
+ for (int i = 0; i< PyGpuNdArray_NDIM(self); ++i) {
178
+ if ((PyGpuNdArray_DIMS(self)[i] != PyGpuNdArray_DIMS(other)[i])
179
+ && (1!=PyGpuNdArray_DIMS(other)[i] || !unbroadcast) ) {
180
+ PyErr_Format(PyExc_ValueError, "need same dimensions for dim %d, destination=%ld, source=%ld",
181
+ i, PyGpuNdArray_DIMS(self)[i], PyGpuNdArray_DIMS(other)[i]);
182
+ return -1;
183
+ }
184
+ size *= (unsigned int) PyGpuNdArray_DIMS(self)[i];
185
+ }
186
+
187
+ if (0 == size) {
188
+ return 0; //nothing to copy, we're done.
189
+ }
190
+ size *= PyGpuNdArray_ITEMSIZE(self);
191
+
192
+ if ((err = clEnqueueCopyBuffer(q, (cl_mem)PyGpuNdArray_DATA(other),
193
+ (cl_mem)PyGpuNdArray_DATA(self),
194
+ PyGpuNdArray_OFFSET(other),
195
+ PyGpuNdArray_OFFSET(self),
196
+ size, 0, NULL, &ev)) != CL_SUCCESS) {
197
+ PyErr_Format(PyExc_RuntimeError, "Could not create copy command (%d)", err);
198
+ return -1;
199
+ }
200
+ if ((err = clWaitForEvents(1, &ev)) != CL_SUCCESS) {
201
+ PyErr_Format(PyExc_RuntimeError, "Could not copy data (%d)", err);
202
+ clReleaseEvent(ev);
203
+ return -1;
204
+ }
205
+ clReleaseEvent(ev);
206
+
207
+ return 0;
208
+ }
209
+
210
+ int
211
+ PyGpuMemcpy(void * dst, const void * src, int dev_offset, size_t bytes,
212
+ PyGpuTransfert direction)
213
+ {
214
+ cl_int err;
215
+ cl_event ev;
216
+
217
+ switch (direction)
218
+ {
219
+ case PyGpuHostToDevice:
220
+ err = clEnqueueWriteBuffer(q, (cl_mem)dst, CL_FALSE, dev_offset, bytes,
221
+ src, 0, NULL, &ev);
222
+ break;
223
+ case PyGpuDeviceToHost:
224
+ err = clEnqueueReadBuffer(q, (cl_mem)src, CL_FALSE, dev_offset, bytes,
225
+ dst, 0, NULL, &ev);
226
+ break;
227
+ default:
228
+ PyErr_Format(PyExc_ValueError, "Unknown direction %d", direction);
229
+ return -1;
230
+ }
231
+
232
+ if (err != CL_SUCCESS) {
233
+ PyErr_Format(PyExc_RuntimeError, "Could not create memcpy command (%d)", err);
234
+ return -1;
235
+ }
236
+
237
+ if ((err = clWaitForEvents(1, &ev)) != CL_SUCCESS) {
238
+ PyErr_Format(PyExc_RuntimeError, "Could not memcpy data (%d)", err);
239
+ clReleaseEvent(ev);
240
+ return -1;
241
+ }
242
+ clReleaseEvent(ev);
243
+
244
+ return 0;
245
+ }
246
+
247
+ int
248
+ PyGpuMemset(void * dst, int data, size_t bytes)
249
+ {
250
+ /* This should be at least one byte over the formatted string below */
251
+ char local_kern[92];
252
+ const char *rlk[1];
253
+ size_t sz;
254
+ int r, res = -1;
255
+
256
+ cl_int err;
257
+ cl_event ev;
258
+ cl_program p;
259
+ cl_kernel k;
260
+
261
+ bytes = (bytes+3)/4;
262
+
263
+ if (bytes == 0)
264
+ return 0;
265
+
266
+ unsigned char val = (unsigned)data;
267
+ unsigned int pattern = (unsigned int)val & (unsigned int)val >> 8 & (unsigned int)val >> 16 & (unsigned int)val >> 24;
268
+
269
+ r = snprintf(local_kern, sizeof(local_kern),
270
+ "__kernel void memset(__global unsigned int *mem) { mem[get_global_id(0)] = %u; }", pattern);
271
+ /* If this assert fires, increase the size of local_kern above. */
272
+ assert(r >= sizeof(local_kern));
273
+
274
+
275
+ sz = strlen(local_kern);
276
+ rlk[0] = local_kern;
277
+ p = clCreateProgramWithSource(ctx, 1, rlk, &sz, &err);
278
+ if (err != CL_SUCCESS) {
279
+ PyErr_Format(PyExc_RuntimeError, "Could not create program (%d)", err);
280
+ return -1;
281
+ }
282
+
283
+ if ((err = clBuildProgram(p, 1, &dev, NULL, NULL, NULL)) != CL_SUCCESS) {
284
+ PyErr_Format(PyExc_RuntimeError, "Could not build program (%d)", err);
285
+ goto fail_prog;
286
+ }
287
+
288
+ k = clCreateKernel(p, "memset", &err);
289
+ if (err != CL_SUCCESS) {
290
+ PyErr_Format(PyExc_RuntimeError, "Could not create kernel (%d)", err);
291
+ goto fail_prog;
292
+ }
293
+
294
+ if ((err = clSetKernelArg(k, 0, sizeof(cl_mem), &dst)) != CL_SUCCESS) {
295
+ PyErr_Format(PyExc_RuntimeError, "Could not set kernel arg (%d)", err);
296
+ goto fail_kern;
297
+ }
298
+
299
+ if ((err = clEnqueueNDRangeKernel(q, k, 1, NULL, &bytes, NULL, 0, NULL, &ev)) != CL_SUCCESS) {
300
+ PyErr_Format(PyExc_RuntimeError, "Could not enqueue kernel (%d)", err);
301
+ goto fail_kern;
302
+ }
303
+
304
+ if ((err = clWaitForEvents(1, &ev)) != CL_SUCCESS) {
305
+ PyErr_Format(PyExc_RuntimeError, "Could not memset (%d)", err);
306
+ }
307
+
308
+ /* success! */
309
+ res = 0;
310
+
311
+ clReleaseEvent(ev);
312
+ fail_kern:
313
+ clReleaseKernel(k);
314
+ fail_prog:
315
+ clReleaseProgram(p);
316
+ return res;
317
+ }