~ubuntu-branches/ubuntu/wily/pyopencl/wily

« back to all changes in this revision

Viewing changes to src/wrapper/wrap_cl_part_1.cpp

  • Committer: Package Import Robot
  • Author(s): Dmitrijs Ledkovs
  • Date: 2013-10-22 18:08:41 UTC
  • mfrom: (2.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20131022180841-1lcaecrns774y1ys
Tags: 2013.1+git20130916-1build1
No change rebuild for Boost 1.54 transition.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
 
11
11
void pyopencl_expose_part_1()
12
12
{
 
13
  py::docstring_options doc_op;
 
14
  doc_op.disable_cpp_signatures();
 
15
 
13
16
  py::def("get_cl_header_version", get_cl_header_version);
14
17
 
15
18
  // {{{ platform
21
24
      .DEF_SIMPLE_METHOD(get_info)
22
25
      .def("get_devices", &cls::get_devices,
23
26
          py::arg("device_type")=CL_DEVICE_TYPE_ALL)
24
 
      .add_property("obj_ptr", &cls::obj_ptr)
25
27
      .def(py::self == py::self)
26
28
      .def(py::self != py::self)
27
29
      .def("__hash__", &cls::hash)
 
30
      PYOPENCL_EXPOSE_TO_FROM_INT_PTR(cl_platform_id)
28
31
      ;
29
32
  }
30
33
 
35
38
    typedef device cls;
36
39
    py::class_<cls, boost::noncopyable>("Device", py::no_init)
37
40
      .DEF_SIMPLE_METHOD(get_info)
38
 
      .add_property("obj_ptr", &cls::obj_ptr)
39
41
      .def(py::self == py::self)
40
42
      .def(py::self != py::self)
41
43
      .def("__hash__", &cls::hash)
45
47
#if PYOPENCL_CL_VERSION >= 0x1020
46
48
      .DEF_SIMPLE_METHOD(create_sub_devices)
47
49
#endif
 
50
      PYOPENCL_EXPOSE_TO_FROM_INT_PTR(cl_device_id)
48
51
      ;
49
52
  }
50
53
 
54
57
 
55
58
  {
56
59
    typedef context cls;
57
 
    py::class_<cls, boost::noncopyable, 
 
60
    py::class_<cls, boost::noncopyable,
58
61
      boost::shared_ptr<cls> >("Context", py::no_init)
59
62
      .def("__init__", make_constructor(create_context,
60
63
            py::default_call_policies(),
63
66
             py::arg("dev_type")=py::object()
64
67
            )))
65
68
      .DEF_SIMPLE_METHOD(get_info)
66
 
      .add_property("obj_ptr", &cls::obj_ptr)
67
69
      .def(py::self == py::self)
68
70
      .def(py::self != py::self)
69
71
      .def("__hash__", &cls::hash)
 
72
      PYOPENCL_EXPOSE_TO_FROM_INT_PTR(cl_context)
70
73
      ;
71
74
  }
72
75
 
85
88
#endif
86
89
      .DEF_SIMPLE_METHOD(flush)
87
90
      .DEF_SIMPLE_METHOD(finish)
88
 
      .add_property("obj_ptr", &cls::obj_ptr)
89
91
      .def(py::self == py::self)
90
92
      .def(py::self != py::self)
91
93
      .def("__hash__", &cls::hash)
 
94
      PYOPENCL_EXPOSE_TO_FROM_INT_PTR(cl_command_queue)
92
95
      ;
93
96
  }
94
97
 
101
104
      .DEF_SIMPLE_METHOD(get_info)
102
105
      .DEF_SIMPLE_METHOD(get_profiling_info)
103
106
      .DEF_SIMPLE_METHOD(wait)
104
 
      .add_property("obj_ptr", &cls::obj_ptr)
105
107
      .def(py::self == py::self)
106
108
      .def(py::self != py::self)
107
109
      .def("__hash__", &cls::hash)
108
 
      .def("from_cl_event_as_int", create_event_wrapper_from_int,
109
 
           py::args("cl_event_as_int"))
 
110
      PYOPENCL_EXPOSE_TO_FROM_INT_PTR(cl_event)
 
111
 
 
112
      // deprecated, remove in 2015.x.
 
113
      .def("from_cl_event_as_int", from_int_ptr<cls, cl_event>,
 
114
          py::return_value_policy<py::manage_new_object>())
110
115
      .staticmethod("from_cl_event_as_int")
111
116
      ;
112
117
  }
118
123
  }
119
124
 
120
125
  DEF_SIMPLE_FUNCTION(wait_for_events);
121
 
  py::def("enqueue_marker", enqueue_marker,
122
 
      (py::arg("queue"), py::arg("wait_for")=py::object()),
123
 
      py::return_value_policy<py::manage_new_object>());
124
 
  py::def("enqueue_barrier", enqueue_barrier,
125
 
      (py::arg("queue"), py::arg("wait_for")=py::object()),
126
 
      py::return_value_policy<py::manage_new_object>());
127
 
 
128
 
  DEF_SIMPLE_FUNCTION(enqueue_wait_for_events);
 
126
 
 
127
#if PYOPENCL_CL_VERSION >= 0x1020
 
128
  py::def("_enqueue_marker_with_wait_list", enqueue_marker_with_wait_list,
 
129
      (py::arg("queue"), py::arg("wait_for")=py::object()),
 
130
      py::return_value_policy<py::manage_new_object>());
 
131
#endif
 
132
  py::def("_enqueue_marker", enqueue_marker,
 
133
      (py::arg("queue")),
 
134
      py::return_value_policy<py::manage_new_object>());
 
135
  py::def("_enqueue_wait_for_events", enqueue_wait_for_events,
 
136
      (py::arg("queue"), py::arg("wait_for")=py::object()));
 
137
 
 
138
#if PYOPENCL_CL_VERSION >= 0x1020
 
139
  py::def("_enqueue_barrier_with_wait_list", enqueue_barrier_with_wait_list,
 
140
      (py::arg("queue"), py::arg("wait_for")=py::object()),
 
141
      py::return_value_policy<py::manage_new_object>());
 
142
#endif
 
143
  py::def("_enqueue_barrier", enqueue_barrier, py::arg("queue"));
129
144
 
130
145
#if PYOPENCL_CL_VERSION >= 0x1010
131
146
  {
152
167
      .def(py::self == py::self)
153
168
      .def(py::self != py::self)
154
169
      .def("__hash__", &cls::hash)
 
170
 
 
171
      .add_property("int_ptr", to_int_ptr<cls>,
 
172
          "Return an integer corresponding to the pointer value "
 
173
          "of the underlying :c:type:`cl_mem`. "
 
174
          "Use :meth:`from_int_ptr` to turn back into a Python object."
 
175
          "\n\n.. versionadded:: 2013.2\n")
155
176
      ;
156
177
  }
157
178
  {
159
180
    py::class_<cls, boost::noncopyable, py::bases<memory_object_holder> >(
160
181
        "MemoryObject", py::no_init)
161
182
      .DEF_SIMPLE_METHOD(release)
162
 
      .add_property("obj_ptr", &cls::obj_ptr)
163
183
      .add_property("hostbuf", &cls::hostbuf)
164
 
      .def("from_cl_mem_as_int", memory_object_from_int,
165
 
          py::args("cl_mem_as_int"))
 
184
 
 
185
      .def("from_int_ptr", memory_object_from_int,
 
186
        "(static method) Return a new Python object referencing the C-level " \
 
187
        ":c:type:`cl_mem` object at the location pointed to " \
 
188
        "by *int_ptr_value*. The relevant :c:func:`clRetain*` function " \
 
189
        "will be called." \
 
190
        "\n\n.. versionadded:: 2013.2\n") \
 
191
      .staticmethod("from_int_ptr")
 
192
 
 
193
      // deprecated, remove in 2015.x
 
194
      .def("from_cl_mem_as_int", memory_object_from_int)
166
195
      .staticmethod("from_cl_mem_as_int")
167
196
      ;
168
197
  }
273
302
  // }}}
274
303
 
275
304
#if PYOPENCL_CL_VERSION >= 0x1020
276
 
  py::def("enqueue_fill_buffer", enqueue_fill_buffer,
 
305
  py::def("_enqueue_fill_buffer", enqueue_fill_buffer,
277
306
      (py::args("queue", "mem", "pattern", "offset", "size"),
278
307
       py::arg("wait_for")=py::object()),
279
308
      py::return_value_policy<py::manage_new_object>());