[Beignet] [PATCH V3 2/3] runtime: tweak max memory allocation size.
Zhigang Gong
zhigang.gong at intel.com
Wed Dec 24 22:16:24 PST 2014
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>
v2:
reduce max constant buffer to 128MB.
v3:
fix the sysinfo usage.
Signed-off-by: Zhigang Gong <zhigang.gong at intel.com>
---
src/cl_device_id.c | 10 ++++++++++
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 711f8ae..d594863 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 three_gb = 3 * 1024 * 1024 * 1024ul;
+ uint64_t totalram = info.totalram * info.mem_unit;
+ ret->global_mem_size = (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..20d72f9 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 = 128 * 1024 * 1024,
.max_constant_args = 8,
.error_correction_support = CL_FALSE,
#ifdef HAS_USERPTR
--
1.8.3.2
More information about the Beignet
mailing list