[Beignet] [PATCH] Runtime: change default tiling mode to TILE_X from TILE_Y.
Zhigang Gong
zhigang.gong at intel.com
Thu May 8 22:19:00 PDT 2014
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 <zhigang.gong at intel.com>
---
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
--
1.8.3.2
More information about the Beignet
mailing list