From e27c34c2ee65713a74aa661b376c262d4886579e Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Wed, 19 Nov 2014 16:54:59 +0100 Subject: [PATCH] opencl backend: do not declare or allocate arrays that are not accessed Signed-off-by: Sven Verdoolaege --- opencl.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/opencl.c b/opencl.c index 60226d1..6391ab1 100644 --- a/opencl.c +++ b/opencl.c @@ -228,6 +228,8 @@ static __isl_give isl_printer *opencl_declare_device_arrays( for (i = 0; i < prog->n_array; ++i) { if (gpu_array_is_read_only_scalar(&prog->array[i])) continue; + if (!prog->array[i].accessed) + continue; p = isl_printer_start_line(p); p = isl_printer_print_str(p, "cl_mem dev_"); p = isl_printer_print_str(p, prog->array[i].name); @@ -292,7 +294,7 @@ static __isl_give isl_printer *allocate_device_array(__isl_take isl_printer *p, return p; } -/* Allocate device arrays. +/* Allocate accessed device arrays. */ static __isl_give isl_printer *opencl_allocate_device_arrays( __isl_take isl_printer *p, struct gpu_prog *prog) @@ -304,6 +306,8 @@ static __isl_give isl_printer *opencl_allocate_device_arrays( if (gpu_array_is_read_only_scalar(array)) continue; + if (!array->accessed) + continue; p = allocate_device_array(p, array); } @@ -1222,7 +1226,7 @@ static __isl_give isl_printer *release_device_array(__isl_take isl_printer *p, return p; } -/* Free the device arrays. +/* Free the accessed device arrays. */ static __isl_give isl_printer *opencl_release_device_arrays( __isl_take isl_printer *p, struct gpu_prog *prog) @@ -1233,6 +1237,8 @@ static __isl_give isl_printer *opencl_release_device_arrays( struct gpu_array_info *array = &prog->array[i]; if (gpu_array_is_read_only_scalar(array)) continue; + if (!array->accessed) + continue; p = release_device_array(p, array); } -- 2.11.4.GIT