From ee3840a5fb03c33d5b352a912508634a58e6a0ed Mon Sep 17 00:00:00 2001 From: Zhigang Gong Date: Fri, 9 May 2014 13:12:28 +0800 Subject: [PATCH] Runtime: change default tiling mode to TILE_X from TILE_Y. Nanhai found that tiling mode does matter the performance much for some cases. So make the tiling mode configurable at runtime and make the default tiling mode as TILE_X which is much better than the original TILE_Y for many cases. At runtime, it is easy to change the default tiling mode as below export OCL_TILING=0 # enable NO_TILE export OCL_TILING=1 # enable TILE_X export OCL_TILING=2 # enable TILE_Y Signed-off-by: Zhigang Gong --- src/cl_mem.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/cl_mem.c b/src/cl_mem.c index 44482f7..5faef4b 100644 --- a/src/cl_mem.c +++ b/src/cl_mem.c @@ -502,6 +502,27 @@ static const uint32_t tilex_h = 8; /* tileX height in number of rows */ static const uint32_t tiley_w = 128; /* tileY width in bytes */ static const uint32_t tiley_h = 32; /* tileY height in number of rows */ +cl_image_tiling_t cl_get_default_tiling(void) +{ + static int initialized = 0; + static cl_image_tiling_t tiling = CL_TILE_X; + if (!initialized) { + char *tilingStr = getenv("OCL_TILING"); + if (tilingStr != NULL) { + switch (tilingStr[0]) { + case '0': tiling = CL_NO_TILE; break; + case '1': tiling = CL_TILE_X; break; + case '2': tiling = CL_TILE_Y; break; + default: + break; + } + } + initialized = 1; + } + + return tiling; +} + static cl_mem _cl_mem_new_image(cl_context ctx, cl_mem_flags flags, @@ -558,7 +579,7 @@ _cl_mem_new_image(cl_context ctx, /* Pick up tiling mode (we do only linear on SNB) */ if (cl_driver_get_ver(ctx->drv) != 6) - tiling = CL_TILE_Y; + tiling = cl_get_default_tiling(); depth = 1; } @@ -579,7 +600,7 @@ _cl_mem_new_image(cl_context ctx, /* Pick up tiling mode (we do only linear on SNB) */ if (cl_driver_get_ver(ctx->drv) != 6) - tiling = CL_TILE_Y; + tiling = cl_get_default_tiling(); } #undef DO_IMAGE_ERROR -- 2.7.4