summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGuo Yejun <yejun.guo@intel.com>2014-11-07 16:19:46 +0800
committerZhigang Gong <zhigang.gong@intel.com>2014-11-07 16:00:46 +0800
commit99e3b583f0d5837601670ca3486cb5ecfd8bf1a1 (patch)
tree9d36bc12724f51cf9aae4c859b913710545ab033 /src
parent075390db926de7bfd2ac853404ab1bcfc8b9c650 (diff)
enable CL_DEVICE_HOST_UNIFIED_MEMORY when userptr is supported
userptr is firstly checked at compile time with libdrm version, but it does not ensure the system has such capability (for exmaple, with old linux kernel), so also take a check at run time for the device info. V2: add runtime check to see if userptr is really supported Signed-off-by: Guo Yejun <yejun.guo@intel.com> Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com> Reviewed-by: Zhenyu Wang <zhenyuw@linux.intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/cl_device_id.c17
-rw-r--r--src/cl_gt_device.h4
2 files changed, 21 insertions, 0 deletions
diff --git a/src/cl_device_id.c b/src/cl_device_id.c
index c911c23f..e3b0c64e 100644
--- a/src/cl_device_id.c
+++ b/src/cl_device_id.c
@@ -31,6 +31,7 @@
#include <assert.h>
#include <stdio.h>
#include <string.h>
+#include <stdlib.h>
#ifndef CL_VERSION_1_2
#define CL_DEVICE_BUILT_IN_KERNELS 0x103F
@@ -401,6 +402,22 @@ brw_gt3_break:
}
}
+#ifdef HAS_USERPTR
+ cl_driver dummy = cl_driver_new(NULL);
+ cl_buffer_mgr bufmgr = cl_driver_get_bufmgr(dummy);
+
+ const size_t sz = 4096;
+ char* host_ptr = (char*)aligned_alloc(4096, sz);
+ 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_driver_delete(dummy);
+#endif
+
return ret;
}
diff --git a/src/cl_gt_device.h b/src/cl_gt_device.h
index 3cd54ebd..c9caa1d9 100644
--- a/src/cl_gt_device.h
+++ b/src/cl_gt_device.h
@@ -60,7 +60,11 @@
.max_constant_buffer_size = 512 << 10,
.max_constant_args = 8,
.error_correction_support = CL_FALSE,
+#ifdef HAS_USERPTR
+.host_unified_memory = CL_TRUE,
+#else
.host_unified_memory = CL_FALSE,
+#endif
.profiling_timer_resolution = 80, /* ns */
.endian_little = CL_TRUE,
.available = CL_TRUE,