summaryrefslogtreecommitdiff
path: root/src/cl_device_id.c
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/cl_device_id.c
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/cl_device_id.c')
-rw-r--r--src/cl_device_id.c17
1 files changed, 17 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;
}