[Beignet] [PATCH V3] ocl20/runtime: take the first 64KB page table entries.

Ruiling Song ruiling.song at intel.com
Mon Dec 21 21:47:17 PST 2015


After we take first 64KB page table entries. we would make sure
the global memory will not be allocated in the range [0, 64KB].
this is needed, so that we can easily differentiate local/global
address space.

v2:
disable reuse.
v3:
move the null_bo from gpgpu to intel_driver_t.
as the gpgpu suffers from frequent construction/destruction.

Signed-off-by: Ruiling Song <ruiling.song at intel.com>
---
 src/intel/intel_driver.c | 7 +++++++
 src/intel/intel_driver.h | 1 +
 src/intel/intel_gpgpu.c  | 3 +++
 3 files changed, 11 insertions(+)

diff --git a/src/intel/intel_driver.c b/src/intel/intel_driver.c
index 7eaa6c5..c2bee9c 100644
--- a/src/intel/intel_driver.c
+++ b/src/intel/intel_driver.c
@@ -138,11 +138,18 @@ intel_driver_context_init(intel_driver_t *driver)
 {
   driver->ctx = drm_intel_gem_context_create(driver->bufmgr);
   assert(driver->ctx);
+  drm_intel_bo *bo = dri_bo_alloc(driver->bufmgr, "null_bo", 64*1024, 4096);
+  drm_intel_bo_set_softpin_offset(bo, 0);
+  // don't reuse it, that would make two bo trying to bind to same address,
+  // which is un-reasonable.
+  drm_intel_bo_disable_reuse(bo);
+  driver->null_bo = bo;
 }
 
 static void
 intel_driver_context_destroy(intel_driver_t *driver)
 {
+  drm_intel_bo_unreference(driver->null_bo);
   if(driver->ctx)
     drm_intel_gem_context_destroy(driver->ctx);
   driver->ctx = NULL;
diff --git a/src/intel/intel_driver.h b/src/intel/intel_driver.h
index 51f0e0d..3be93c2 100644
--- a/src/intel/intel_driver.h
+++ b/src/intel/intel_driver.h
@@ -79,6 +79,7 @@ typedef struct intel_driver
 {
   dri_bufmgr *bufmgr;
   drm_intel_context *ctx;
+  drm_intel_bo *null_bo;
   int fd;
   int device_id;
   int gen_ver;
diff --git a/src/intel/intel_gpgpu.c b/src/intel/intel_gpgpu.c
index 110c36f..442140f 100644
--- a/src/intel/intel_gpgpu.c
+++ b/src/intel/intel_gpgpu.c
@@ -955,6 +955,7 @@ intel_gpgpu_state_init(intel_gpgpu_t *gpgpu,
   size_aux = ALIGN(size_aux, 4096);
 
   bo = dri_bo_alloc(gpgpu->drv->bufmgr, "AUX_BUFFER", size_aux, 4096);
+
   if (!bo || dri_bo_map(bo, 1) != 0) {
     fprintf(stderr, "%s:%d: %s.\n", __FILE__, __LINE__, strerror(errno));
     if (bo)
@@ -1817,6 +1818,8 @@ static void
 intel_gpgpu_states_setup(intel_gpgpu_t *gpgpu, cl_gpgpu_kernel *kernel)
 {
   gpgpu->ker = kernel;
+  intel_gpgpu_setup_bti(gpgpu, gpgpu->drv->null_bo, 0, 64*1024, 0xfe, I965_SURFACEFORMAT_RAW);
+
   intel_gpgpu_build_idrt(gpgpu, kernel);
   dri_bo_unmap(gpgpu->aux_buf.bo);
 }
-- 
2.4.1



More information about the Beignet mailing list