提交 c87d998e 编写于 作者: M Megvii Engine Team

feat(mgb): add interface to support opencl IO zero copy when inference

GitOrigin-RevId: a1d7021892f430378c4eebd46152495d450efc61
上级 af6cdb20
......@@ -658,4 +658,36 @@ void CompNode::ImplBase::add_callback(megdnn::thin_function<void()>&&) {
locator().to_string().c_str());
}
void CompNode::map_to_cpu(void* ptr, size_t size, bool blocking) {
m_impl->map_to_cpu(ptr, size, blocking);
}
void CompNode::unmap_to_gpu(void* ptr, size_t size) {
m_impl->unmap_to_gpu(ptr, size);
}
void* CompNode::get_logical_addr_by_host_ptr(void* ptr, size_t size) {
return m_impl->get_logical_addr_by_host_ptr(ptr, size);
}
void CompNode::ImplBase::map_to_cpu(void* ptr, size_t size, bool blocking) {
MGB_MARK_USED_VAR(ptr);
MGB_MARK_USED_VAR(size);
MGB_MARK_USED_VAR(blocking);
mgb_assert(false, "No map_to_cpu Impl");
}
void CompNode::ImplBase::unmap_to_gpu(void* ptr, size_t size) {
MGB_MARK_USED_VAR(ptr);
MGB_MARK_USED_VAR(size);
mgb_assert(false, "No unmap_to_gpu Impl");
}
void* CompNode::ImplBase::get_logical_addr_by_host_ptr(void* ptr, size_t size) {
MGB_MARK_USED_VAR(ptr);
MGB_MARK_USED_VAR(size);
mgb_assert(false, "No get_logical_addr_by_host_ptr Impl");
return nullptr;
}
// vim: syntax=cpp.doxygen foldmethod=marker foldmarker=f{{{,f}}}
......@@ -322,6 +322,21 @@ public:
MGE_WIN_DECLSPEC_FUC static DeviceProperties get_device_prop(
int dev, DeviceType device_type);
/*!
* \brief get control of host ptr to user
*/
MGE_WIN_DECLSPEC_FUC void map_to_cpu(void* ptr, size_t size, bool blocking = false);
/*!
* \brief release control of host ptr to system
*/
MGE_WIN_DECLSPEC_FUC void unmap_to_gpu(void* ptr, size_t size);
/*!
* \brief get logical address by host ptr
*/
MGE_WIN_DECLSPEC_FUC void* get_logical_addr_by_host_ptr(void* ptr, size_t size);
/* =================== synchronization ======================== */
class Event;
......@@ -573,6 +588,12 @@ protected:
peer_copy_to(dest_impl, dest.get_ptr(), src.get_ptr(), size);
}
virtual void map_to_cpu(void* ptr, size_t size, bool blocking = false);
virtual void unmap_to_gpu(void* ptr, size_t size);
virtual void* get_logical_addr_by_host_ptr(void* ptr, size_t size);
virtual size_t get_mem_addr_alignment() = 0;
virtual size_t get_mem_padding();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册