Skip to content
Snippets Groups Projects
Commit 4b365ab3 authored by Andreas Klöckner's avatar Andreas Klöckner
Browse files

Support for host memory flags in PageLockedMemoryPool.

parent d9eb807d
No related branches found
No related tags found
No related merge requests found
......@@ -70,8 +70,8 @@ namespace pycuda
bool m_stop_holding;
public:
memory_pool()
: m_held_blocks(0), m_active_blocks(0), m_stop_holding(false)
memory_pool(Allocator const &alloc=Allocator())
: m_allocator(alloc), m_held_blocks(0), m_active_blocks(0), m_stop_holding(false)
{
}
......
......@@ -48,13 +48,20 @@ namespace
class host_allocator
{
private:
unsigned m_flags;
public:
typedef void *pointer_type;
typedef unsigned int size_type;
host_allocator(unsigned flags=0)
: m_flags(flags)
{ }
pointer_type allocate(size_type s)
{
return cuda::mem_alloc_host(s);
return cuda::mem_alloc_host(s, m_flags);
}
void free(pointer_type p)
......@@ -225,12 +232,21 @@ void pycuda_expose_tools()
expose_memory_pool(wrapper);
}
{
typedef host_allocator cl;
py::class_<cl> wrapper("PageLockedAllocator",
py::init<py::optional<unsigned> >());
}
{
typedef pycuda::memory_pool<host_allocator> cl;
py::class_<
cl, boost::noncopyable,
boost::shared_ptr<cl> > wrapper("PageLockedMemoryPool");
boost::shared_ptr<cl> > wrapper(
"PageLockedMemoryPool",
py::init<py::optional<host_allocator const &> >()
);
wrapper
.def("allocate", host_pool_allocate,
(py::arg("shape"), py::arg("dtype"), py::arg("order")="C"));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment