diff options
author | Guo Yejun <yejun.guo@intel.com> | 2014-12-02 09:31:01 +0800 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@intel.com> | 2014-12-02 17:16:59 +0800 |
commit | befcef65ce5a87a91967974a53d5e77e2b16d136 (patch) | |
tree | f578af6d14082dd097c7edf41a1247b4cc8caea2 /src/cl_device_id.c | |
parent | 6d6ea43aacbe65d9f9e2167d1824c35f128eec79 (diff) |
enable CL_MEM_ALLOC_HOST_PTR with user_ptr to avoid copy between GPU/CPU
when user ptr is enabled, allocates page aligned system memory for
CL_MEM_ALLOC_HOST_PTR inside the driver and wraps it as GPU memory
to avoid the copy between GPU and CPU.
and also do some code refine for the relative user_ptr code.
tests verified: beignet/utest, conformance/basic, buffers, mem_host_flags
Signed-off-by: Guo Yejun <yejun.guo@intel.com>
Reviewed-by: "Yang, Rong R" <rong.r.yang@intel.com>
Diffstat (limited to 'src/cl_device_id.c')
-rw-r--r-- | src/cl_device_id.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/cl_device_id.c b/src/cl_device_id.c index 5ef0bdea..711f8ae7 100644 --- a/src/cl_device_id.c +++ b/src/cl_device_id.c @@ -27,6 +27,7 @@ #include "cl_thread.h" #include "CL/cl.h" #include "cl_gbe_loader.h" +#include "cl_alloc.h" #include <assert.h> #include <stdio.h> @@ -407,15 +408,14 @@ brw_gt3_break: cl_buffer_mgr bufmgr = cl_driver_get_bufmgr(dummy); const size_t sz = 4096; - void* host_ptr = NULL; - int err = posix_memalign(&host_ptr, 4096, sz); - if (err == 0) { + void* host_ptr = cl_aligned_malloc(sz, 4096);; + if (host_ptr != NULL) { cl_buffer bo = cl_buffer_alloc_userptr(bufmgr, "CL memory object", host_ptr, sz, 0); if (bo == NULL) ret->host_unified_memory = CL_FALSE; else cl_buffer_unreference(bo); - free(host_ptr); + cl_free(host_ptr); } else ret->host_unified_memory = CL_FALSE; |