[Beignet] [PATCH 2/3] runtime: tweak max memory allocation size.

Zhigang Gong zhigang.gong at linux.intel.com
Tue Dec 23 18:17:44 PST 2014


Please ignore this version. I just sent a new version of this patch.
The other patches in this patchset are ok.

On Wed, Dec 24, 2014 at 10:13:34AM +0800, Zhigang Gong wrote:
> Increase the maximum memory allocation size to at least 512MB and
> will set it to larger if the system has more total memory.
> 
> This tweak will make darktable happy to handle big pictures.
> 
> Signed-off-by: Zhigang Gong <zhigang.gong at intel.com>
> ---
>  src/cl_device_id.c | 9 +++++++++
>  src/cl_gt_device.h | 4 ++--
>  2 files changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/src/cl_device_id.c b/src/cl_device_id.c
> index 711f8ae..0bbe031 100644
> --- a/src/cl_device_id.c
> +++ b/src/cl_device_id.c
> @@ -33,6 +33,7 @@
>  #include <stdio.h>
>  #include <string.h>
>  #include <stdlib.h>
> +#include <sys/sysinfo.h>
>  
>  #ifndef CL_VERSION_1_2
>  #define CL_DEVICE_BUILT_IN_KERNELS 0x103F
> @@ -422,6 +423,14 @@ brw_gt3_break:
>    cl_driver_delete(dummy);
>  #endif
>  
> +  struct sysinfo info;
> +  if (sysinfo(&info) == 0) {
> +    size_t three_gb = 3 * 1024 * 1024 * 1024ul; 
> +    ret->global_mem_size = (info.totalram > three_gb) ? 
> +                            three_gb : info.totalram;
> +    ret->max_mem_alloc_size = ret->global_mem_size / 2;
> +  }
> +
>    return ret;
>  }
>  
> diff --git a/src/cl_gt_device.h b/src/cl_gt_device.h
> index 4faa15a..32f3073 100644
> --- a/src/cl_gt_device.h
> +++ b/src/cl_gt_device.h
> @@ -40,7 +40,7 @@
>  .native_vector_width_half = 8,
>  .preferred_wg_sz_mul = 16,
>  .address_bits = 32,
> -.max_mem_alloc_size = 256 * 1024 * 1024,
> +.max_mem_alloc_size = 512 * 1024 * 1024,
>  .image_support = CL_TRUE,
>  .max_read_image_args = 128,
>  .max_write_image_args = 8,
> @@ -57,7 +57,7 @@
>  .double_fp_config = 0,
>  .global_mem_cache_type = CL_READ_WRITE_CACHE,
>  .global_mem_size = 1024 * 1024 * 1024,
> -.max_constant_buffer_size = 512 << 10,
> +.max_constant_buffer_size = 256 * 1024 * 1024,
>  .max_constant_args = 8,
>  .error_correction_support = CL_FALSE,
>  #ifdef HAS_USERPTR
> -- 
> 1.8.3.2
> 
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list