[Beignet] [PATCH] driver/runtime: get global mem size dynamically
Pan Xiuli
xiuli.pan at intel.com
Fri Oct 9 00:46:46 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 | 7 +++++++
2 files changed, 10 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..32198e8 100644
--- a/src/intel/intel_driver.c
+++ b/src/intel/intel_driver.c
@@ -130,6 +130,7 @@ intel_driver_memman_init(intel_driver_t *driver)
drm_intel_bufmgr_gem_enable_reuse(driver->bufmgr);
driver->device_id = drm_intel_bufmgr_gem_get_devid(driver->bufmgr);
intel_driver_aub_dump(driver);
+ if(getenv("DRMDBG")) drm_intel_bufmgr_set_debug(driver->bufmgr,1);
return 1;
}
@@ -829,6 +830,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 = total_mem;
intel_driver_context_destroy(driver);
intel_driver_close(driver);
--
2.1.4
More information about the Beignet
mailing list