pyopencl 2024.2.2__cp310-cp310-win_amd64.whl → 2024.2.5__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 (99) 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/.gitignore +21 -0
  8. pyopencl/compyte/ndarray/Makefile +31 -0
  9. pyopencl/compyte/ndarray/gpu_ndarray.h +35 -0
  10. pyopencl/compyte/ndarray/pygpu_language.h +207 -0
  11. pyopencl/compyte/ndarray/pygpu_language_cuda.cu +622 -0
  12. pyopencl/compyte/ndarray/pygpu_language_opencl.cpp +317 -0
  13. pyopencl/compyte/ndarray/pygpu_ndarray.cpp +1546 -0
  14. pyopencl/compyte/ndarray/pygpu_ndarray.h +71 -0
  15. pyopencl/compyte/ndarray/pygpu_ndarray_object.h +232 -0
  16. pyopencl/tools.py +60 -56
  17. pyopencl/version.py +9 -3
  18. {pyopencl-2024.2.2.dist-info → pyopencl-2024.2.5.dist-info}/METADATA +105 -105
  19. pyopencl-2024.2.5.dist-info/RECORD +56 -0
  20. {pyopencl-2024.2.2.dist-info → pyopencl-2024.2.5.dist-info}/WHEEL +1 -1
  21. pyopencl-2024.2.2.data/data/CITATION.cff +0 -74
  22. pyopencl-2024.2.2.data/data/CMakeLists.txt +0 -83
  23. pyopencl-2024.2.2.data/data/Makefile.in +0 -21
  24. pyopencl-2024.2.2.data/data/README.rst +0 -70
  25. pyopencl-2024.2.2.data/data/README_SETUP.txt +0 -34
  26. pyopencl-2024.2.2.data/data/aksetup_helper.py +0 -1013
  27. pyopencl-2024.2.2.data/data/configure.py +0 -6
  28. pyopencl-2024.2.2.data/data/contrib/cldis.py +0 -91
  29. pyopencl-2024.2.2.data/data/contrib/fortran-to-opencl/README +0 -29
  30. pyopencl-2024.2.2.data/data/contrib/fortran-to-opencl/translate.py +0 -1441
  31. pyopencl-2024.2.2.data/data/contrib/pyopencl.vim +0 -84
  32. pyopencl-2024.2.2.data/data/doc/Makefile +0 -23
  33. pyopencl-2024.2.2.data/data/doc/algorithm.rst +0 -214
  34. pyopencl-2024.2.2.data/data/doc/array.rst +0 -305
  35. pyopencl-2024.2.2.data/data/doc/conf.py +0 -26
  36. pyopencl-2024.2.2.data/data/doc/howto.rst +0 -105
  37. pyopencl-2024.2.2.data/data/doc/index.rst +0 -137
  38. pyopencl-2024.2.2.data/data/doc/make_constants.py +0 -561
  39. pyopencl-2024.2.2.data/data/doc/misc.rst +0 -885
  40. pyopencl-2024.2.2.data/data/doc/runtime.rst +0 -51
  41. pyopencl-2024.2.2.data/data/doc/runtime_const.rst +0 -30
  42. pyopencl-2024.2.2.data/data/doc/runtime_gl.rst +0 -78
  43. pyopencl-2024.2.2.data/data/doc/runtime_memory.rst +0 -527
  44. pyopencl-2024.2.2.data/data/doc/runtime_platform.rst +0 -184
  45. pyopencl-2024.2.2.data/data/doc/runtime_program.rst +0 -364
  46. pyopencl-2024.2.2.data/data/doc/runtime_queue.rst +0 -182
  47. pyopencl-2024.2.2.data/data/doc/subst.rst +0 -36
  48. pyopencl-2024.2.2.data/data/doc/tools.rst +0 -4
  49. pyopencl-2024.2.2.data/data/doc/types.rst +0 -42
  50. pyopencl-2024.2.2.data/data/examples/black-hole-accretion.py +0 -2227
  51. pyopencl-2024.2.2.data/data/examples/demo-struct-reduce.py +0 -75
  52. pyopencl-2024.2.2.data/data/examples/demo.py +0 -39
  53. pyopencl-2024.2.2.data/data/examples/demo_array.py +0 -32
  54. pyopencl-2024.2.2.data/data/examples/demo_array_svm.py +0 -37
  55. pyopencl-2024.2.2.data/data/examples/demo_elementwise.py +0 -34
  56. pyopencl-2024.2.2.data/data/examples/demo_elementwise_complex.py +0 -53
  57. pyopencl-2024.2.2.data/data/examples/demo_mandelbrot.py +0 -183
  58. pyopencl-2024.2.2.data/data/examples/demo_meta_codepy.py +0 -56
  59. pyopencl-2024.2.2.data/data/examples/demo_meta_template.py +0 -55
  60. pyopencl-2024.2.2.data/data/examples/dump-performance.py +0 -38
  61. pyopencl-2024.2.2.data/data/examples/dump-properties.py +0 -86
  62. pyopencl-2024.2.2.data/data/examples/gl_interop_demo.py +0 -84
  63. pyopencl-2024.2.2.data/data/examples/gl_particle_animation.py +0 -218
  64. pyopencl-2024.2.2.data/data/examples/ipython-demo.ipynb +0 -203
  65. pyopencl-2024.2.2.data/data/examples/median-filter.py +0 -99
  66. pyopencl-2024.2.2.data/data/examples/n-body.py +0 -1070
  67. pyopencl-2024.2.2.data/data/examples/narray.py +0 -37
  68. pyopencl-2024.2.2.data/data/examples/noisyImage.jpg +0 -0
  69. pyopencl-2024.2.2.data/data/examples/pi-monte-carlo.py +0 -1166
  70. pyopencl-2024.2.2.data/data/examples/svm.py +0 -82
  71. pyopencl-2024.2.2.data/data/examples/transpose.py +0 -229
  72. pyopencl-2024.2.2.data/data/pytest.ini +0 -3
  73. pyopencl-2024.2.2.data/data/src/bitlog.cpp +0 -51
  74. pyopencl-2024.2.2.data/data/src/bitlog.hpp +0 -83
  75. pyopencl-2024.2.2.data/data/src/clinfo_ext.h +0 -134
  76. pyopencl-2024.2.2.data/data/src/mempool.hpp +0 -444
  77. pyopencl-2024.2.2.data/data/src/pyopencl_ext.h +0 -77
  78. pyopencl-2024.2.2.data/data/src/tools.hpp +0 -90
  79. pyopencl-2024.2.2.data/data/src/wrap_cl.cpp +0 -61
  80. pyopencl-2024.2.2.data/data/src/wrap_cl.hpp +0 -5853
  81. pyopencl-2024.2.2.data/data/src/wrap_cl_part_1.cpp +0 -369
  82. pyopencl-2024.2.2.data/data/src/wrap_cl_part_2.cpp +0 -702
  83. pyopencl-2024.2.2.data/data/src/wrap_constants.cpp +0 -1274
  84. pyopencl-2024.2.2.data/data/src/wrap_helpers.hpp +0 -213
  85. pyopencl-2024.2.2.data/data/src/wrap_mempool.cpp +0 -738
  86. pyopencl-2024.2.2.data/data/test/add-vectors-32.spv +0 -0
  87. pyopencl-2024.2.2.data/data/test/add-vectors-64.spv +0 -0
  88. pyopencl-2024.2.2.data/data/test/empty-header.h +0 -1
  89. pyopencl-2024.2.2.data/data/test/test_algorithm.py +0 -1180
  90. pyopencl-2024.2.2.data/data/test/test_array.py +0 -2392
  91. pyopencl-2024.2.2.data/data/test/test_arrays_in_structs.py +0 -100
  92. pyopencl-2024.2.2.data/data/test/test_clmath.py +0 -529
  93. pyopencl-2024.2.2.data/data/test/test_clrandom.py +0 -75
  94. pyopencl-2024.2.2.data/data/test/test_enqueue_copy.py +0 -271
  95. pyopencl-2024.2.2.data/data/test/test_wrapper.py +0 -1565
  96. pyopencl-2024.2.2.dist-info/LICENSE +0 -282
  97. pyopencl-2024.2.2.dist-info/RECORD +0 -123
  98. pyopencl-2024.2.2.dist-info/top_level.txt +0 -1
  99. {pyopencl-2024.2.2.data/data → pyopencl-2024.2.5.dist-info/licenses}/LICENSE +0 -0
@@ -1,702 +0,0 @@
1
- // Wrap CL
2
- //
3
- // Copyright (C) 2009-18 Andreas Kloeckner
4
- //
5
- // Permission is hereby granted, free of charge, to any person
6
- // obtaining a copy of this software and associated documentation
7
- // files (the "Software"), to deal in the Software without
8
- // restriction, including without limitation the rights to use,
9
- // copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- // copies of the Software, and to permit persons to whom the
11
- // Software is furnished to do so, subject to the following
12
- // conditions:
13
- //
14
- // The above copyright notice and this permission notice shall be
15
- // included in all copies or substantial portions of the Software.
16
- //
17
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
- // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19
- // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
- // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21
- // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22
- // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23
- // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24
- // OTHER DEALINGS IN THE SOFTWARE.
25
-
26
-
27
- #include <memory>
28
- #define NO_IMPORT_ARRAY
29
- #define PY_ARRAY_UNIQUE_SYMBOL pyopencl_ARRAY_API
30
-
31
- #include "wrap_cl.hpp"
32
-
33
-
34
-
35
-
36
- namespace pyopencl {
37
- #if PYOPENCL_CL_VERSION >= 0x1020
38
- py::object image_desc_dummy_getter(cl_image_desc &desc)
39
- {
40
- return py::none();
41
- }
42
-
43
- void image_desc_set_shape(cl_image_desc &desc, py::object py_shape)
44
- {
45
- COPY_PY_REGION_TRIPLE(shape);
46
- desc.image_width = shape[0];
47
- desc.image_height = shape[1];
48
- desc.image_depth = shape[2];
49
- desc.image_array_size = shape[2];
50
- }
51
-
52
- void image_desc_set_pitches(cl_image_desc &desc, py::object py_pitches)
53
- {
54
- COPY_PY_PITCH_TUPLE(pitches);
55
- desc.image_row_pitch = pitches[0];
56
- desc.image_slice_pitch = pitches[1];
57
- }
58
-
59
- void image_desc_set_buffer(cl_image_desc &desc, memory_object *mobj)
60
- {
61
- if (mobj)
62
- desc.buffer = mobj->data();
63
- else
64
- desc.buffer = 0;
65
- }
66
-
67
- #endif
68
- }
69
-
70
-
71
-
72
-
73
- using namespace pyopencl;
74
-
75
-
76
-
77
-
78
- void pyopencl_expose_part_2(py::module_ &m)
79
- {
80
- // {{{ image
81
-
82
- #if PYOPENCL_CL_VERSION >= 0x1020
83
- {
84
- typedef cl_image_desc cls;
85
- py::class_<cls>(m, "ImageDescriptor")
86
- .def(py::init<>())
87
- .def_rw("image_type", &cls::image_type)
88
- .def_prop_rw("shape", &image_desc_dummy_getter, image_desc_set_shape)
89
- .def_rw("array_size", &cls::image_array_size)
90
- .def_prop_rw("pitches", &image_desc_dummy_getter, image_desc_set_pitches)
91
- .def_rw("num_mip_levels", &cls::num_mip_levels)
92
- .def_rw("num_samples", &cls::num_samples)
93
- .def_prop_rw("buffer", &image_desc_dummy_getter, image_desc_set_buffer,
94
- py::arg("buffer").none()
95
- )
96
- ;
97
- }
98
- #endif
99
-
100
- {
101
- typedef image cls;
102
- py::class_<cls, memory_object>(m, "Image", py::dynamic_attr())
103
- .def(
104
- "__init__",
105
- [](
106
- cls *self,
107
- context const &ctx,
108
- cl_mem_flags flags,
109
- cl_image_format const &fmt,
110
- py::sequence shape,
111
- py::sequence pitches,
112
- py::object buffer)
113
- {
114
- return create_image(self, ctx, flags, fmt, shape, pitches, buffer);
115
- },
116
- py::arg("context"),
117
- py::arg("flags"),
118
- py::arg("format"),
119
- py::arg("shape")=py::none(),
120
- py::arg("pitches")=py::none(),
121
- py::arg("hostbuf")=py::none()
122
- )
123
- #if PYOPENCL_CL_VERSION >= 0x1020
124
- .def(
125
- "__init__",
126
- [](
127
- cls *self,
128
- context const &ctx,
129
- cl_mem_flags flags,
130
- cl_image_format const &fmt,
131
- cl_image_desc &desc,
132
- py::object buffer)
133
- {
134
- create_image_from_desc(self, ctx, flags, fmt, desc, buffer);
135
- },
136
- py::arg("context"),
137
- py::arg("flags"),
138
- py::arg("format"),
139
- py::arg("desc"),
140
- py::arg("hostbuf")=py::none()
141
- )
142
- #endif
143
- .DEF_SIMPLE_METHOD(get_image_info)
144
- ;
145
- }
146
-
147
- {
148
- typedef cl_image_format cls;
149
- py::class_<cls>(m, "ImageFormat")
150
- .def(
151
- "__init__",
152
- [](cls *self, cl_channel_order ord, cl_channel_type tp)
153
- {
154
- set_image_format(self, ord, tp);
155
- })
156
- .def_rw("channel_order", &cls::image_channel_order)
157
- .def_rw("channel_data_type", &cls::image_channel_data_type)
158
- .def_prop_ro("channel_count", &get_image_format_channel_count)
159
- .def_prop_ro("dtype_size", &get_image_format_channel_dtype_size)
160
- .def_prop_ro("itemsize", &get_image_format_item_size)
161
- ;
162
- }
163
-
164
- DEF_SIMPLE_FUNCTION(get_supported_image_formats);
165
-
166
- m.def("_enqueue_read_image", enqueue_read_image,
167
- py::arg("queue"),
168
- py::arg("mem"),
169
- py::arg("origin"),
170
- py::arg("region"),
171
- py::arg("hostbuf"),
172
- py::arg("row_pitch")=0,
173
- py::arg("slice_pitch")=0,
174
- py::arg("wait_for")=py::none(),
175
- py::arg("is_blocking")=true
176
- );
177
- m.def("_enqueue_write_image", enqueue_write_image,
178
- py::arg("queue"),
179
- py::arg("mem"),
180
- py::arg("origin"),
181
- py::arg("region"),
182
- py::arg("hostbuf"),
183
- py::arg("row_pitch")=0,
184
- py::arg("slice_pitch")=0,
185
- py::arg("wait_for")=py::none(),
186
- py::arg("is_blocking")=true
187
- );
188
-
189
- m.def("_enqueue_copy_image", enqueue_copy_image,
190
- py::arg("queue"),
191
- py::arg("src"),
192
- py::arg("dest"),
193
- py::arg("src_origin"),
194
- py::arg("dest_origin"),
195
- py::arg("region"),
196
- py::arg("wait_for")=py::none()
197
- );
198
- m.def("_enqueue_copy_image_to_buffer", enqueue_copy_image_to_buffer,
199
- py::arg("queue"),
200
- py::arg("src"),
201
- py::arg("dest"),
202
- py::arg("origin"),
203
- py::arg("region"),
204
- py::arg("offset"),
205
- py::arg("wait_for")=py::none()
206
- );
207
- m.def("_enqueue_copy_buffer_to_image", enqueue_copy_buffer_to_image,
208
- py::arg("queue"),
209
- py::arg("src"),
210
- py::arg("dest"),
211
- py::arg("offset"),
212
- py::arg("origin"),
213
- py::arg("region"),
214
- py::arg("wait_for")=py::none()
215
- );
216
-
217
- #if PYOPENCL_CL_VERSION >= 0x1020
218
- m.def("enqueue_fill_image", enqueue_fill_image,
219
- py::arg("queue"),
220
- py::arg("mem"),
221
- py::arg("color"),
222
- py::arg("origin"),
223
- py::arg("region"),
224
- py::arg("wait_for")=py::none()
225
- );
226
- #endif
227
-
228
- // }}}
229
-
230
- // {{{ pipe
231
-
232
- {
233
- typedef pyopencl::pipe cls;
234
- py::class_<cls, memory_object>(m, "Pipe", py::dynamic_attr())
235
- #if PYOPENCL_CL_VERSION >= 0x2000
236
- .def(
237
- "__init__",
238
- [](
239
- cls *self,
240
- context const &ctx,
241
- cl_mem_flags flags,
242
- cl_uint pipe_packet_size,
243
- cl_uint pipe_max_packets,
244
- py::sequence py_props)
245
- {
246
- create_pipe(self, ctx, flags, pipe_packet_size, pipe_max_packets, py_props);
247
- },
248
- py::arg("context"),
249
- py::arg("flags"),
250
- py::arg("packet_size"),
251
- py::arg("max_packets"),
252
- py::arg("properties")=py::make_tuple()
253
- )
254
- #endif
255
- .DEF_SIMPLE_METHOD(get_pipe_info)
256
- ;
257
- }
258
-
259
- // }}}
260
-
261
- // {{{ memory_map
262
- {
263
- typedef memory_map cls;
264
- py::class_<cls>(m, "MemoryMap", py::dynamic_attr())
265
- .def("release", &cls::release,
266
- py::arg("queue").none(true)=nullptr,
267
- py::arg("wait_for").none(true)=py::none()
268
- )
269
- ;
270
- }
271
-
272
- // FIXME: Reenable in pypy
273
- #ifndef PYPY_VERSION
274
- m.def("enqueue_map_buffer", enqueue_map_buffer,
275
- py::arg("queue"),
276
- py::arg("buf"),
277
- py::arg("flags"),
278
- py::arg("offset"),
279
- py::arg("shape"),
280
- py::arg("dtype"),
281
- py::arg("order")="C",
282
- py::arg("strides").none(true)=py::none(),
283
- py::arg("wait_for").none(true)=py::none(),
284
- py::arg("is_blocking")=true);
285
- m.def("enqueue_map_image", enqueue_map_image,
286
- py::arg("queue"),
287
- py::arg("img"),
288
- py::arg("flags"),
289
- py::arg("origin"),
290
- py::arg("region"),
291
- py::arg("shape"),
292
- py::arg("dtype"),
293
- py::arg("order")="C",
294
- py::arg("strides").none(true)=py::none(),
295
- py::arg("wait_for").none(true)=py::none(),
296
- py::arg("is_blocking")=true);
297
- #endif
298
-
299
- // }}}
300
-
301
- // {{{ svm_pointer
302
-
303
- #if PYOPENCL_CL_VERSION >= 0x2000
304
- {
305
- typedef svm_pointer cls;
306
- py::class_<cls>(m, "SVMPointer", py::dynamic_attr())
307
- // For consistency, it may seem appropriate to use int_ptr here, but
308
- // that would work on both buffers and SVM, and passing a buffer pointer to
309
- // a kernel is going to lead to a bad time.
310
- .def_prop_ro("svm_ptr",
311
- [](cls &self) { return (intptr_t) self.svm_ptr(); })
312
- .def_prop_ro("size", [](cls &self) -> py::object
313
- {
314
- try
315
- {
316
- return py::cast(self.size());
317
- }
318
- catch (size_not_available)
319
- {
320
- return py::none();
321
- }
322
- })
323
- .def_prop_ro("buf", [](cls &self) -> py::ndarray<py::numpy, unsigned char, py::ndim<1>> {
324
- size_t size;
325
- try
326
- {
327
- size = self.size();
328
- }
329
- catch (size_not_available)
330
- {
331
- throw pyopencl::error("SVMPointer buffer protocol", CL_INVALID_VALUE,
332
- "size of SVM is not known");
333
- }
334
-
335
- return py::ndarray<py::numpy, unsigned char, py::ndim<1>>(
336
- /* data = */ self.svm_ptr(),
337
- /* ndim = */ 1,
338
- /* shape pointer = */ &size,
339
- /* owner = */ py::handle());
340
- }, py::rv_policy::reference_internal)
341
- ;
342
- }
343
-
344
- // }}}
345
-
346
- // {{{ svm_arg_wrapper
347
-
348
- {
349
- typedef svm_arg_wrapper cls;
350
- py::class_<cls, svm_pointer>(m, "SVM", py::dynamic_attr())
351
- .def(py::init<py::object>())
352
- ;
353
- }
354
-
355
- // }}}
356
-
357
- // {{{ svm_allocation
358
-
359
- {
360
- typedef svm_allocation cls;
361
- py::class_<cls, svm_pointer>(m, "SVMAllocation", py::dynamic_attr())
362
- .def(py::init<std::shared_ptr<context>, size_t, cl_uint, cl_svm_mem_flags, const command_queue *>(),
363
- py::arg("context"),
364
- py::arg("size"),
365
- py::arg("alignment"),
366
- py::arg("flags"),
367
- py::arg("queue").none(true)=py::none()
368
- )
369
- .DEF_SIMPLE_METHOD(release)
370
- .def("enqueue_release", &cls::enqueue_release,
371
- ":returns: a :class:`pyopencl.Event`\n\n"
372
- "|std-enqueue-blurb|",
373
- py::arg("queue").none(true)=py::none(),
374
- py::arg("wait_for").none(true)=py::none()
375
- )
376
- PYOPENCL_EXPOSE_EQUALITY_TESTS
377
- .def("__hash__", [](cls &self) { return (intptr_t) self.svm_ptr(); })
378
- .def("bind_to_queue", &cls::bind_to_queue,
379
- py::arg("queue"))
380
- .DEF_SIMPLE_METHOD(unbind_from_queue)
381
-
382
- // only for diagnostic/debugging/testing purposes!
383
- .def_prop_ro("_queue",
384
- [](cls const &self) -> py::object
385
- {
386
- cl_command_queue queue = self.queue();
387
- if (queue)
388
- return py::cast(new command_queue(queue, true));
389
- else
390
- return py::none();
391
- })
392
- ;
393
- }
394
-
395
- // }}}
396
-
397
- // {{{ svm operations
398
-
399
- m.def("_enqueue_svm_memcpy", enqueue_svm_memcpy,
400
- py::arg("queue"),
401
- py::arg("is_blocking"),
402
- py::arg("dst"),
403
- py::arg("src"),
404
- py::arg("wait_for").none(true)=py::none(),
405
- py::arg("byte_count").none(true)=py::none()
406
- );
407
-
408
- m.def("_enqueue_svm_memfill", enqueue_svm_memfill,
409
- py::arg("queue"),
410
- py::arg("dst"),
411
- py::arg("pattern"),
412
- py::arg("byte_count").none(true)=py::none(),
413
- py::arg("wait_for").none(true)=py::none()
414
- );
415
-
416
- m.def("_enqueue_svm_map", enqueue_svm_map,
417
- py::arg("queue"),
418
- py::arg("is_blocking"),
419
- py::arg("flags"),
420
- py::arg("svm"),
421
- py::arg("wait_for").none(true)=py::none(),
422
- py::arg("size").none(true)=py::none()
423
- );
424
-
425
- m.def("_enqueue_svm_unmap", enqueue_svm_unmap,
426
- py::arg("queue"),
427
- py::arg("svm"),
428
- py::arg("wait_for").none(true)=py::none()
429
- );
430
- #endif
431
-
432
- #if PYOPENCL_CL_VERSION >= 0x2010
433
- m.def("_enqueue_svm_migrate_mem", enqueue_svm_migratemem,
434
- py::arg("queue"),
435
- py::arg("svms"),
436
- py::arg("flags").none(true)=py::none(),
437
- py::arg("wait_for").none(true)=py::none()
438
- );
439
- #endif
440
-
441
- // }}}
442
-
443
- // {{{ sampler
444
- {
445
- typedef sampler cls;
446
- py::class_<cls>(m, "Sampler", py::dynamic_attr())
447
- #if PYOPENCL_CL_VERSION >= 0x2000
448
- .def(py::init<context const &, py::sequence>())
449
- #endif
450
- .def(py::init<context const &, bool, cl_addressing_mode, cl_filter_mode>())
451
- .DEF_SIMPLE_METHOD(get_info)
452
- PYOPENCL_EXPOSE_EQUALITY_TESTS
453
- .def("__hash__", &cls::hash)
454
- PYOPENCL_EXPOSE_TO_FROM_INT_PTR(cl_sampler)
455
- ;
456
- }
457
-
458
- // }}}
459
-
460
- // {{{ program
461
- {
462
- typedef program cls;
463
- py::enum_<cls::program_kind_type>(m, "program_kind")
464
- .value("UNKNOWN", cls::KND_UNKNOWN)
465
- .value("SOURCE", cls::KND_SOURCE)
466
- .value("BINARY", cls::KND_BINARY)
467
- .value("IL", cls::KND_IL)
468
- ;
469
-
470
- py::class_<cls>(m, "_Program", py::dynamic_attr())
471
- .def(
472
- "__init__",
473
- [](cls *self, context &ctx, std::string const &src)
474
- {
475
- create_program_with_source(self, ctx, src);
476
- },
477
- py::arg("context"),
478
- py::arg("src"))
479
- .def(
480
- "__init__",
481
- [](cls *self, context &ctx, py::sequence devices, py::sequence binaries)
482
- {
483
- return create_program_with_binary(self, ctx, devices, binaries);
484
- },
485
- py::arg("context"),
486
- py::arg("devices"),
487
- py::arg("binaries"))
488
- #if (PYOPENCL_CL_VERSION >= 0x1020) || \
489
- ((PYOPENCL_CL_VERSION >= 0x1030) && defined(__APPLE__))
490
- .def_static("create_with_built_in_kernels",
491
- create_program_with_built_in_kernels,
492
- py::arg("context"),
493
- py::arg("devices"),
494
- py::arg("kernel_names"))
495
- #endif
496
- .DEF_SIMPLE_METHOD(kind)
497
- .DEF_SIMPLE_METHOD(get_info)
498
- .DEF_SIMPLE_METHOD(get_build_info)
499
- .def("_build", &cls::build,
500
- py::arg("options")="",
501
- py::arg("devices").none(true)=py::none())
502
- #if PYOPENCL_CL_VERSION >= 0x1020
503
- .def("compile", &cls::compile,
504
- py::arg("options")="",
505
- py::arg("devices").none(true)=py::none(),
506
- py::arg("headers")=py::list())
507
- .def_static("link", &link_program,
508
- py::arg("context"),
509
- py::arg("programs"),
510
- py::arg("options")="",
511
- py::arg("devices").none(true)=py::none()
512
- )
513
- #endif
514
- #if PYOPENCL_CL_VERSION >= 0x2020
515
- .def("set_specialization_constant", &cls::set_specialization_constant,
516
- py::arg("spec_id"),
517
- py::arg("buffer"))
518
- #endif
519
- PYOPENCL_EXPOSE_EQUALITY_TESTS
520
- .def("__hash__", &cls::hash)
521
- .def("all_kernels", create_kernels_in_program)
522
- PYOPENCL_EXPOSE_TO_FROM_INT_PTR(cl_program)
523
- ;
524
- }
525
-
526
- #if (PYOPENCL_CL_VERSION >= 0x2010)
527
- m.def("_create_program_with_il", create_program_with_il);
528
- #endif
529
-
530
- #if PYOPENCL_CL_VERSION >= 0x1020
531
- m.def("unload_platform_compiler", unload_platform_compiler);
532
- #endif
533
-
534
- // }}}
535
-
536
- // {{{ kernel
537
-
538
- {
539
- typedef kernel cls;
540
- py::class_<cls>(m, "Kernel", py::dynamic_attr())
541
- .def(py::init<const program &, std::string const &>())
542
- .DEF_SIMPLE_METHOD(get_info)
543
- .DEF_SIMPLE_METHOD(get_work_group_info)
544
- #if PYOPENCL_CL_VERSION >= 0x2010
545
- .DEF_SIMPLE_METHOD(clone)
546
- #endif
547
- .def("_set_arg_null", &cls::set_arg_null)
548
- .def("_set_arg_buf", &cls::set_arg_buf)
549
- #if PYOPENCL_CL_VERSION >= 0x2000
550
- .def("_set_arg_svm", &cls::set_arg_svm)
551
- #endif
552
- .def("_set_arg_multi",
553
- [](cls &knl, py::tuple indices_and_args)
554
- {
555
- set_arg_multi(
556
- [&](cl_uint i, py::handle arg) { knl.set_arg(i, arg); },
557
- indices_and_args);
558
- })
559
- .def("_set_arg_buf_multi",
560
- [](cls &knl, py::tuple indices_and_args)
561
- {
562
- set_arg_multi(
563
- [&](cl_uint i, py::handle arg) { knl.set_arg_buf(i, arg); },
564
- indices_and_args);
565
- })
566
- .def("_set_arg_buf_pack_multi",
567
- [](cls &knl, py::tuple indices_chars_and_args)
568
- {
569
- set_arg_multi(
570
- [&](cl_uint i, py::handle typechar, py::handle arg)
571
- { knl.set_arg_buf_pack(i, typechar, arg); },
572
- indices_chars_and_args);
573
- })
574
- .DEF_SIMPLE_METHOD(set_arg)
575
- #if PYOPENCL_CL_VERSION >= 0x1020
576
- .DEF_SIMPLE_METHOD(get_arg_info)
577
- #endif
578
- PYOPENCL_EXPOSE_EQUALITY_TESTS
579
- .def("__hash__", &cls::hash)
580
- PYOPENCL_EXPOSE_TO_FROM_INT_PTR(cl_kernel)
581
- #if PYOPENCL_CL_VERSION >= 0x2010
582
- .def("get_sub_group_info", &cls::get_sub_group_info,
583
- py::arg("device"),
584
- py::arg("param"),
585
- py::arg("input_value").none(true)=py::none()
586
- )
587
- #endif
588
- ;
589
- }
590
-
591
- {
592
- typedef local_memory cls;
593
- py::class_<cls>(m, "LocalMemory", py::dynamic_attr())
594
- .def(
595
- py::init<size_t>(),
596
- py::arg("size"))
597
- .def_prop_ro("size", &cls::size)
598
- ;
599
- }
600
-
601
- m.def("enqueue_nd_range_kernel", enqueue_nd_range_kernel,
602
- py::arg("queue"),
603
- py::arg("kernel"),
604
- py::arg("global_work_size"),
605
- py::arg("local_work_size").none(true),
606
- py::arg("global_work_offset").none(true)=py::none(),
607
- py::arg("wait_for").none(true)=py::none(),
608
- py::arg("g_times_l")=false,
609
- py::arg("allow_empty_ndrange")=false
610
- );
611
-
612
- // TODO: clEnqueueNativeKernel
613
- // }}}
614
-
615
- // {{{ GL interop
616
- DEF_SIMPLE_FUNCTION(have_gl);
617
-
618
- #ifdef HAVE_GL
619
-
620
- #ifdef __APPLE__
621
- DEF_SIMPLE_FUNCTION(get_apple_cgl_share_group);
622
- #endif /* __APPLE__ */
623
-
624
- {
625
- typedef gl_buffer cls;
626
- py::class_<cls, memory_object>(m, "GLBuffer", py::dynamic_attr())
627
- .def(
628
- "__init__",
629
- [](cls *self, context &ctx, cl_mem_flags flags, GLuint bufobj)
630
- {
631
- create_from_gl_buffer(self, ctx, flags, bufobj);
632
- },
633
- py::arg("context"),
634
- py::arg("flags"),
635
- py::arg("bufobj"))
636
- .def("get_gl_object_info", get_gl_object_info)
637
- ;
638
- }
639
-
640
- {
641
- typedef gl_renderbuffer cls;
642
- py::class_<cls, memory_object>(m, "GLRenderBuffer", py::dynamic_attr())
643
- .def(
644
- "__init__",
645
- [](cls *self, context &ctx, cl_mem_flags flags, GLuint bufobj)
646
- {
647
- create_from_gl_renderbuffer(self, ctx, flags, bufobj);
648
- },
649
- py::arg("context"),
650
- py::arg("flags"),
651
- py::arg("bufobj"))
652
- .def("get_gl_object_info", get_gl_object_info)
653
- ;
654
- }
655
-
656
- {
657
- typedef gl_texture cls;
658
- py::class_<cls, image>(m, "GLTexture", py::dynamic_attr())
659
- .def(
660
- "__init__",
661
- [](cls *self, context &ctx, cl_mem_flags flags, GLenum texture_target,
662
- GLint miplevel, GLuint texture, unsigned dims)
663
- {
664
- create_from_gl_texture(self, ctx, flags, texture_target, miplevel, texture, dims);
665
- },
666
- py::arg("context"),
667
- py::arg("flags"),
668
- py::arg("texture_target"),
669
- py::arg("miplevel"),
670
- py::arg("texture"),
671
- py::arg("dims"))
672
- .def("get_gl_object_info", get_gl_object_info)
673
- .DEF_SIMPLE_METHOD(get_gl_texture_info)
674
- ;
675
- }
676
-
677
- m.def("enqueue_acquire_gl_objects", enqueue_acquire_gl_objects,
678
- py::arg("queue"),
679
- py::arg("mem_objects"),
680
- py::arg("wait_for").none(true)=py::none()
681
- );
682
- m.def("enqueue_release_gl_objects", enqueue_release_gl_objects,
683
- py::arg("queue"),
684
- py::arg("mem_objects"),
685
- py::arg("wait_for").none(true)=py::none()
686
- );
687
-
688
- #if defined(cl_khr_gl_sharing) && (cl_khr_gl_sharing >= 1)
689
- m.def("get_gl_context_info_khr", get_gl_context_info_khr,
690
- py::arg("properties"),
691
- py::arg("param_name"),
692
- py::arg("platform").none(true)=py::none()
693
- );
694
- #endif
695
-
696
- #endif
697
- // }}}
698
-
699
- }
700
-
701
-
702
- // vim: foldmethod=marker