summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPan Xiuli <xiuli.pan@intel.com>2016-06-03 11:01:41 +0800
committerYang Rong <rong.r.yang@intel.com>2016-06-12 17:22:46 +0800
commitdbb90f603ed7481fff3187514d790dade3d4850b (patch)
tree8d00da5b54a648573fbe3a70eb650b74dafa7c02 /src
parent0d65ba8238dcbe8b40a8425f33c4c10c23ae9b1a (diff)
downloadbeignet-dbb90f603ed7481fff3187514d790dade3d4850b.tar.gz
Runtime: Disable image hostptr for default
Image with hostptr can not use tiling and can be very slow when need access image. Disable image hostptr for default for good profermance. Add an option OCL_IMAGE_HOSTPTR to enable ture image hostptr. Signed-off-by: Pan Xiuli <xiuli.pan@intel.com> Reviewed-by: Yang Rong <rong.r.yang@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/cl_mem.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/cl_mem.c b/src/cl_mem.c
index 229bc0a2..2172511b 100644
--- a/src/cl_mem.c
+++ b/src/cl_mem.c
@@ -744,6 +744,13 @@ _cl_mem_new_image(cl_context ctx,
size_t sz = 0, aligned_pitch = 0, aligned_slice_pitch = 0, aligned_h = 0;
size_t origin_width = w; // for image1d buffer work around.
cl_image_tiling_t tiling = CL_NO_TILE;
+ int enable_true_hostptr = 0;
+
+ // can't use BVAR (backend/src/sys/cvar.hpp) here as it's C++
+ const char *env = getenv("OCL_IMAGE_HOSTPTR");
+ if (env != NULL) {
+ sscanf(env, "%i", &enable_true_hostptr);
+ }
/* Check flags consistency */
if (UNLIKELY((flags & (CL_MEM_COPY_HOST_PTR | CL_MEM_USE_HOST_PTR)) && data == NULL)) {
@@ -846,7 +853,7 @@ _cl_mem_new_image(cl_context ctx,
#undef DO_IMAGE_ERROR
uint8_t enableUserptr = 0;
- if (ctx->device->host_unified_memory && data != NULL && (flags & CL_MEM_USE_HOST_PTR)) {
+ if (enable_true_hostptr && ctx->device->host_unified_memory && data != NULL && (flags & CL_MEM_USE_HOST_PTR)) {
int cacheline_size = 0;
cl_get_device_info(ctx->device, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, sizeof(cacheline_size), &cacheline_size, NULL);
if (ALIGN((unsigned long)data, cacheline_size) == (unsigned long)data &&