[Beignet] [PATCH] driver/runtime: get global mem size dynamically
Pan Xiuli
xiuli.pan at intel.com
Fri Oct 9 00:56:11 PDT 2015
The gen8 and higher gpu can have more than 2G mem, so we dynamically
get the global mem size.
Signed-off-by: Pan Xiuli <xiuli.pan at intel.com>
---
src/cl_device_id.c | 6 +++---
src/intel/intel_driver.c | 6 ++++++
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/cl_device_id.c b/src/cl_device_id.c
index 78d2cf4..c3bd35f 100644
--- a/src/cl_device_id.c
+++ b/src/cl_device_id.c
@@ -550,10 +550,10 @@ skl_gt4_break:
struct sysinfo info;
if (sysinfo(&info) == 0) {
- uint64_t two_gb = 2 * 1024 * 1024 * 1024ul;
+ uint64_t totalgpumem = ret->global_mem_size;
uint64_t totalram = info.totalram * info.mem_unit;
- ret->global_mem_size = (totalram > two_gb) ?
- two_gb : info.totalram;
+ ret->global_mem_size = (totalram > totalgpumem) ?
+ totalgpumem: totalram;
ret->max_mem_alloc_size = ret->global_mem_size / 2;
}
diff --git a/src/intel/intel_driver.c b/src/intel/intel_driver.c
index 035a103..1f286f7 100644
--- a/src/intel/intel_driver.c
+++ b/src/intel/intel_driver.c
@@ -829,6 +829,12 @@ intel_update_device_info(cl_device_id device)
if (IS_CHERRYVIEW(device->device_id))
printf(CHV_CONFIG_WARNING);
#endif
+ //We should get the device memory dynamically, also the
+ //mapablce mem size usage is unknown. Still use global_mem_size/2
+ //as max_mem_alloc_size in cl_get_gt_device.
+ size_t total_mem,map_mem;
+ drm_intel_get_aperture_sizes(driver->fd,&map_mem,&total_mem);
+ device->global_mem_size = (cl_ulong)total_mem;
intel_driver_context_destroy(driver);
intel_driver_close(driver);
--
2.1.4
More information about the Beignet
mailing list