diff --git a/src/wrapper/mempool.cpp b/src/wrapper/mempool.cpp index 918d3d0d5ca9e166ef04937c9963fd512d1e5bfa..f4088cbd961576b47571fb053c22c8c1f4f04900 100644 --- a/src/wrapper/mempool.cpp +++ b/src/wrapper/mempool.cpp @@ -102,7 +102,7 @@ namespace template - class context_dependent_memory_pool : + class context_dependent_memory_pool : public pycuda::memory_pool, public pycuda::explicit_context_dependent { @@ -117,12 +117,13 @@ namespace - class pooled_device_allocation - : public pycuda::context_dependent, - public pycuda::pooled_allocation > - { + class pooled_device_allocation + : public pycuda::context_dependent, + public pycuda::pooled_allocation >, + public pycuda::pointer_holder_base + { private: - typedef + typedef pycuda::pooled_allocation > super; @@ -132,7 +133,7 @@ namespace : super(p, s) { } - operator CUdeviceptr() + virtual CUdeviceptr get_pointer() const { return ptr(); } }; @@ -149,22 +150,11 @@ namespace - PyObject *pooled_device_allocation_to_long(pooled_device_allocation const &da) - { -#if defined(_WIN32) && defined(_WIN64) - return PyLong_FromUnsignedLongLong(da.ptr()); -#else - return PyLong_FromUnsignedLong(da.ptr()); -#endif - } - - - - class pooled_host_allocation + class pooled_host_allocation : public pycuda::pooled_allocation > { private: - typedef + typedef pycuda::pooled_allocation > super; @@ -193,7 +183,7 @@ namespace back_inserter(dims)); std::auto_ptr alloc( - new pooled_host_allocation( + new pooled_host_allocation( pool, tp_descr->elsize*pycuda::size_from_dims(dims.size(), &dims.front()))); NPY_ORDER order = PyArray_CORDER; @@ -249,7 +239,7 @@ void pycuda_expose_tools() typedef context_dependent_memory_pool cl; py::class_< - cl, boost::noncopyable, + cl, boost::noncopyable, boost::shared_ptr > wrapper("DeviceMemoryPool"); wrapper .def("allocate", device_pool_allocate, @@ -269,7 +259,7 @@ void pycuda_expose_tools() typedef pycuda::memory_pool cl; py::class_< - cl, boost::noncopyable, + cl, boost::noncopyable, boost::shared_ptr > wrapper( "PageLockedMemoryPool", py::init >() @@ -284,12 +274,9 @@ void pycuda_expose_tools() { typedef pooled_device_allocation cl; - py::class_( + py::class_ >( "PooledDeviceAllocation", py::no_init) .DEF_SIMPLE_METHOD(free) - .def("__int__", &cl::ptr) - .def("__long__", pooled_device_allocation_to_long) - .def("__index__", pooled_device_allocation_to_long) .def("__len__", &cl::size) ;