diff --git a/src/wrapper/wrap_cl.hpp b/src/wrapper/wrap_cl.hpp index af524fd9b7bdb3d984352ce10c2fb63227ad1a88..95ebc9b0448870973aa9843b6c17944d7cc14c87 100644 --- a/src/wrapper/wrap_cl.hpp +++ b/src/wrapper/wrap_cl.hpp @@ -4236,6 +4236,13 @@ namespace pyopencl PyArray_Descr *tp_descr; if (PyArray_DescrConverter(dtype.ptr(), &tp_descr) != NPY_SUCCEED) throw py::error_already_set(); + cl_mem_flags mem_flags; + PYOPENCL_CALL_GUARDED(clGetMemObjectInfo, + (mem_obj.data(), CL_MEM_FLAGS, sizeof(mem_flags), &mem_flags, 0)); + if (!(mem_flags & CL_MEM_USE_HOST_PTR)) + throw pyopencl::error("MemoryObject.get_host_array", CL_INVALID_VALUE, + "Only MemoryObject with USE_HOST_PTR " + "is supported."); py::extract<npy_intp> shape_as_int(shape); std::vector<npy_intp> dims;