summaryrefslogtreecommitdiff
path: root/backend/src
diff options
context:
space:
mode:
authorJunyan He <junyan.he@intel.com>2016-03-10 14:23:32 +0800
committerJunyan He <junyan.he@intel.com>2016-03-10 14:23:32 +0800
commitff56c683a93c56bb0a768922ea1fb90ec653a8bc (patch)
tree9e19df6ab703ea6ddd9de68a01585e58642aaf9f /backend/src
parentc5afe5121fa6e0ff1d761aefa6f393969affe4ac (diff)
d
Diffstat (limited to 'backend/src')
-rw-r--r--backend/src/driver/cl_gen_batchbuffer.cpp2
-rw-r--r--backend/src/driver/cl_gen_context.cpp20
-rw-r--r--backend/src/driver/cl_gen_device_id.cpp17
-rw-r--r--backend/src/driver/cl_gen_driver.c47
-rw-r--r--backend/src/driver/cl_gen_driver.h7
-rw-r--r--backend/src/driver/cl_gen_driver.hpp103
-rw-r--r--backend/src/driver/cl_gen_gpu_state.cpp2
-rw-r--r--backend/src/driver/cl_gen_gpu_state.hpp (renamed from backend/src/driver/cl_gen_gpu_state.h)0
8 files changed, 125 insertions, 73 deletions
diff --git a/backend/src/driver/cl_gen_batchbuffer.cpp b/backend/src/driver/cl_gen_batchbuffer.cpp
index e1c38d53..b3ec531e 100644
--- a/backend/src/driver/cl_gen_batchbuffer.cpp
+++ b/backend/src/driver/cl_gen_batchbuffer.cpp
@@ -17,7 +17,7 @@
*/
#include <errno.h>
-#include "cl_gen_gpu_state.h"
+#include "cl_gen_gpu_state.hpp"
#define CMD_MI (0x0 << 29)
#define CMD_2D (0x2 << 29)
diff --git a/backend/src/driver/cl_gen_context.cpp b/backend/src/driver/cl_gen_context.cpp
index 2df2945d..807783d2 100644
--- a/backend/src/driver/cl_gen_context.cpp
+++ b/backend/src/driver/cl_gen_context.cpp
@@ -23,16 +23,32 @@ extern "C" { // for the C header files
#ifdef __cplusplus
}
#endif /* __cplusplus */
+#include "cl_gen_driver.hpp"
#include "sys/assert.hpp"
#include "sys/alloc.hpp"
+GenGPUContext::GenGPUContext(dri_bufmgr *bufmgr)
+{
+ ctx = drm_intel_gem_context_create(bufmgr);
+ GBE_ASSERT(ctx);
+ this->bufmgr = bufmgr;
+}
+
+GenGPUContext::~GenGPUContext(void)
+{
+ if(ctx)
+ drm_intel_gem_context_destroy(ctx);
+}
extern "C"
cl_int GenCreateContext(cl_context context, const cl_device_id device,
const cl_context_properties* properties)
{
- /* So far, nothing to do. */
GBE_ASSERT(getGenContextPrivate(context, device) == NULL);
+
+// GenGPUContext gpuCtx = GBE_NEW(GenGPUContext, );
+
+
return CL_SUCCESS;
}
@@ -40,6 +56,6 @@ extern "C"
cl_int GenReleaseContext(cl_context context, const cl_device_id device)
{
/* So far, nothing to do. */
- GBE_ASSERT(getGenContextPrivate(context, device) == NULL);
+ GBE_ASSERT(getGenContextPrivate(context, device) != NULL);
return CL_SUCCESS;
}
diff --git a/backend/src/driver/cl_gen_device_id.cpp b/backend/src/driver/cl_gen_device_id.cpp
index 6eec6e14..aa4def3c 100644
--- a/backend/src/driver/cl_gen_device_id.cpp
+++ b/backend/src/driver/cl_gen_device_id.cpp
@@ -25,10 +25,8 @@ extern "C" { // for the C header files
#include <assert.h>
#include <fcntl.h>
#include <unistd.h>
-#include <i915_drm.h>
#include <sys/ioctl.h>
#include <sys/sysinfo.h>
-#include <intel_bufmgr.h>
#include "cl_platform_id.h"
#include "cl_device_id.h"
#include "cl_gen_driver.h"
@@ -36,6 +34,7 @@ extern "C" { // for the C header files
#ifdef __cplusplus
}
#endif /* __cplusplus */
+#include "cl_gen_driver.hpp"
#include "sys/assert.hpp"
#include "sys/alloc.hpp"
@@ -59,19 +58,6 @@ static cl_device_id gen_device;
static _cl_extensions gen_device_extensions;
static char gen_ext_string[CL_MAX_EXTENSION_LENGTH];
-struct GenGPUDevice {
- dri_bufmgr *bufmgr;
- int fd;
- bool from_x11;
- int device_id;
- int gen_ver;
- cl_uint max_thread_per_unit;
- cl_uint sub_slice_count;
- cl_ulong scratch_mem_size;
- GenGPUDevice();
- ~GenGPUDevice();
-};
-
static GenGPUDevice* getGPUDevice(cl_device_id device)
{
return reinterpret_cast<GenGPUDevice*>(getGenDevicePrivate(device));
@@ -86,6 +72,7 @@ static int gpgpuDeviceInit(GenGPUDevice *gpu)
if (!gpu->bufmgr)
return 0;
+ drm_intel_bufmgr_gem_enable_reuse(gpu->bufmgr);
gpu->device_id = drm_intel_bufmgr_gem_get_devid(gpu->bufmgr);
#if EMULATE_GEN
diff --git a/backend/src/driver/cl_gen_driver.c b/backend/src/driver/cl_gen_driver.c
index 70d215a6..e050cef9 100644
--- a/backend/src/driver/cl_gen_driver.c
+++ b/backend/src/driver/cl_gen_driver.c
@@ -18,53 +18,6 @@
#include "cl_gen_driver.h"
-static int findIndexByDevice(cl_context ctx, cl_device_id device)
-{
- cl_uint i;
- for (i = 0; i < ctx->device_num; i++) {
- if (ctx->devices[i] == device)
- return (int)i;
- }
-
- return -1;
-}
-
-void* getGenDevicePrivate(cl_device_id device)
-{
- return device->pdata;
-}
-void setGenDevicePrivate(cl_device_id device, void* pdata)
-{
- device->pdata = pdata;
-}
-void* getGenContextPrivate(cl_context ctx, cl_device_id device)
-{
- int index;
-
- if (ctx->device_num == 1)
- return device->pdata;
-
- index = findIndexByDevice(ctx, device);
-
- if (index >= 0)
- return ((void**)(ctx->pdata))[index];
-
- return NULL;
-}
-void setGenContextPrivate(cl_context ctx, cl_device_id device, void* pdata)
-{
- int index;
-
- if (ctx->device_num == 1)
- device->pdata = pdata;
-
- index = findIndexByDevice(ctx, device);
-
- assert(index >= 0);
- if (index >= 0)
- ((void**)(ctx->pdata))[index] = pdata;
-}
-
_cl_driver clgenDriver = {
.init = GenDriverInit,
.get_device_ids = GenGetDeviceIDs,
diff --git a/backend/src/driver/cl_gen_driver.h b/backend/src/driver/cl_gen_driver.h
index 3a30ff43..97086b56 100644
--- a/backend/src/driver/cl_gen_driver.h
+++ b/backend/src/driver/cl_gen_driver.h
@@ -23,8 +23,6 @@ extern "C" {
#endif /* __cplusplus */
#include <assert.h>
-#include "cl_device_id.h"
-#include "cl_context.h"
#include "cl_driver.h"
extern _cl_driver clgenDriver;
@@ -41,11 +39,6 @@ cl_int GenReleaseContext(cl_context context, const cl_device_id device);
int dri2OpenX11(void);
void dri2CloseX11(void);
-void* getGenDevicePrivate(cl_device_id device);
-void setGenDevicePrivate(cl_device_id device, void* pdata);
-void* getGenContextPrivate(cl_context ctx, cl_device_id device);
-void setGenContextPrivate(cl_context ctx, cl_device_id device, void* pdata);
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/backend/src/driver/cl_gen_driver.hpp b/backend/src/driver/cl_gen_driver.hpp
new file mode 100644
index 00000000..5c7469bb
--- /dev/null
+++ b/backend/src/driver/cl_gen_driver.hpp
@@ -0,0 +1,103 @@
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+#ifndef __CL_GEN_DRIVER_HPP__
+#define __CL_GEN_DRIVER_HPP__
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+#include <i915_drm.h>
+#include <intel_bufmgr.h>
+#include "cl_driver.h"
+#include "cl_device_id.h"
+#include "cl_context.h"
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#include "sys/platform.hpp"
+
+INLINE int findIndexByDevice(cl_context ctx, cl_device_id device)
+{
+ cl_uint i;
+ for (i = 0; i < ctx->device_num; i++) {
+ if (ctx->devices[i] == device)
+ return (int)i;
+ }
+
+ return -1;
+}
+
+INLINE void* getGenDevicePrivate(cl_device_id device)
+{
+ return device->pdata;
+}
+
+INLINE void setGenDevicePrivate(cl_device_id device, void* pdata)
+{
+ device->pdata = pdata;
+}
+
+INLINE void* getGenContextPrivate(cl_context ctx, cl_device_id device)
+{
+ int index;
+
+ if (ctx->device_num == 1)
+ return device->pdata;
+
+ index = findIndexByDevice(ctx, device);
+
+ if (index >= 0)
+ return ((void**)(ctx->pdata))[index];
+
+ return NULL;
+}
+
+INLINE void setGenContextPrivate(cl_context ctx, cl_device_id device, void* pdata)
+{
+ int index;
+
+ if (ctx->device_num == 1)
+ device->pdata = pdata;
+
+ index = findIndexByDevice(ctx, device);
+
+ assert(index >= 0);
+ if (index >= 0)
+ ((void**)(ctx->pdata))[index] = pdata;
+}
+
+struct GenGPUDevice {
+ dri_bufmgr *bufmgr;
+ int fd;
+ bool from_x11;
+ int device_id;
+ int gen_ver;
+ cl_uint max_thread_per_unit;
+ cl_uint sub_slice_count;
+ cl_ulong scratch_mem_size;
+ GenGPUDevice();
+ ~GenGPUDevice();
+};
+
+struct GenGPUContext {
+ dri_bufmgr *bufmgr;
+ drm_intel_context *ctx;
+ GenGPUContext(dri_bufmgr *bufmgr);
+ ~GenGPUContext(void);
+};
+
+#endif /* __CL_GEN_DRIVER_HPP__ */
diff --git a/backend/src/driver/cl_gen_gpu_state.cpp b/backend/src/driver/cl_gen_gpu_state.cpp
index bb127f7d..456dd933 100644
--- a/backend/src/driver/cl_gen_gpu_state.cpp
+++ b/backend/src/driver/cl_gen_gpu_state.cpp
@@ -15,7 +15,7 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
-#include "cl_gen_gpu_state.h"
+#include "cl_gen_gpu_state.hpp"
#include "cl_gen_gpu_structs.h"
#include "../ocl_common_defines.h"
#include "../backend/program.h" // for BTI_RESERVED_NUM
diff --git a/backend/src/driver/cl_gen_gpu_state.h b/backend/src/driver/cl_gen_gpu_state.hpp
index ee366650..ee366650 100644
--- a/backend/src/driver/cl_gen_gpu_state.h
+++ b/backend/src/driver/cl_gen_gpu_state.hpp