diff options
author | Zhigang Gong <zhigang.gong@intel.com> | 2014-12-24 09:21:28 +0800 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@intel.com> | 2015-01-04 16:54:58 +0800 |
commit | 3ed25511247c2b886d58d839b30260732479d6d2 (patch) | |
tree | 7f6c9e484210a7479c3a4dcfcbe4e78c4861750c /src | |
parent | 4b65235bb7db3df2d1491f1de962d5a92414685b (diff) |
runtime: tweak max memory allocation size.
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@intel.com>
v2:
reduce max constant buffer to 128MB.
v3:
fix the sysinfo usage.
Signed-off-by: Zhigang Gong <zhigang.gong@intel.com>
Tested-by: "Meng, Mengmeng" <mengmeng.meng@intel.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/cl_device_id.c | 10 | ||||
-rw-r--r-- | src/cl_gt_device.h | 4 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/cl_device_id.c b/src/cl_device_id.c index 711f8ae7..34532975 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,15 @@ brw_gt3_break: cl_driver_delete(dummy); #endif + struct sysinfo info; + if (sysinfo(&info) == 0) { + uint64_t two_gb = 2 * 1024 * 1024 * 1024ul; + uint64_t totalram = info.totalram * info.mem_unit; + ret->global_mem_size = (totalram > two_gb) ? + two_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 69aff76e..09503273 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 = BTI_MAX_READ_IMAGE_ARGS, .max_write_image_args = BTI_MAX_WRITE_IMAGE_ARGS, @@ -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 = 128 * 1024 * 1024, .max_constant_args = 8, .error_correction_support = CL_FALSE, #ifdef HAS_USERPTR |