[Beignet] [PATCH 04/11] Runtime: Apply base object to cl_device_id

junyan.he at inbox.com junyan.he at inbox.com
Tue Jul 19 11:25:50 UTC 2016


From: Junyan He <junyan.he at intel.com>

Signed-off-by: Junyan He <junyan.he at intel.com>
---
 src/cl_device_id.c |   16 +++++++++++++++-
 src/cl_device_id.h |    8 +++++---
 src/cl_gt_device.h |    1 -
 3 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/src/cl_device_id.c b/src/cl_device_id.c
index 66666ea..3294f9d 100644
--- a/src/cl_device_id.c
+++ b/src/cl_device_id.c
@@ -600,6 +600,7 @@ bxt_break:
   if (ret == NULL)
     return NULL;
 
+  CL_OBJECT_INIT_BASE(ret, CL_OBJECT_DEVICE_MAGIC);
   if (!CompilerSupported()) {
     ret->compiler_available = CL_FALSE;
     //ret->linker_available = CL_FALSE;
@@ -887,10 +888,23 @@ cl_get_device_info(cl_device_id     device,
     DECL_FIELD(PARTITION_PROPERTIES, partition_property)
     DECL_FIELD(PARTITION_AFFINITY_DOMAIN, affinity_domain)
     DECL_FIELD(PARTITION_TYPE, partition_type)
-    DECL_FIELD(REFERENCE_COUNT, device_reference_count)
     DECL_FIELD(IMAGE_PITCH_ALIGNMENT, image_pitch_alignment)
     DECL_FIELD(IMAGE_BASE_ADDRESS_ALIGNMENT, image_base_address_alignment)
 
+    case CL_DEVICE_REFERENCE_COUNT:
+    {
+      cl_uint dev_ref = CL_OBJECT_GET_REF(device);
+      if (param_value_size_ret) {
+        *param_value_size_ret = sizeof(cl_uint);
+        if (!param_value)
+          return CL_SUCCESS;
+      }
+      if (param_value_size < sizeof(cl_uint))
+        return CL_INVALID_VALUE;
+      memcpy(param_value, &dev_ref, sizeof(cl_uint));
+      return CL_SUCCESS;
+    }
+
     case CL_DRIVER_VERSION:
       if (param_value_size_ret) {
         *param_value_size_ret = device->driver_version_sz;
diff --git a/src/cl_device_id.h b/src/cl_device_id.h
index 7db125b..abb6403 100644
--- a/src/cl_device_id.h
+++ b/src/cl_device_id.h
@@ -22,10 +22,10 @@
 
 #define EXTENSTION_LENGTH 512
 
-#include "cl_khr_icd.h"
+#include "cl_base_object.h"
 /* Store complete information about the device */
 struct _cl_device_id {
-  DEFINE_ICD(dispatch)
+  _cl_base_object base;
   cl_device_type device_type;
   cl_uint  device_id;
   cl_uint  vendor_id;
@@ -117,7 +117,6 @@ struct _cl_device_id {
   cl_device_partition_property partition_property[3];
   cl_device_affinity_domain    affinity_domain;
   cl_device_partition_property partition_type[3];
-  cl_uint      device_reference_count;
   uint32_t atomic_test_result;
   uint32_t image_pitch_alignment;
   uint32_t image_base_address_alignment;
@@ -126,6 +125,9 @@ struct _cl_device_id {
   void* cmrt_device;  //realtype: CmDevice*
 };
 
+#define CL_OBJECT_DEVICE_MAGIC 0x2acaddcca8853c52LL
+#define CL_OBJECT_IS_DEVICE(obj) (((cl_base_object)obj)->magic == CL_OBJECT_DEVICE_MAGIC)
+
 /* Get a device from the given platform */
 extern cl_int cl_get_device_ids(cl_platform_id    platform,
                                 cl_device_type    device_type,
diff --git a/src/cl_gt_device.h b/src/cl_gt_device.h
index 70a0a54..d27c1ad 100644
--- a/src/cl_gt_device.h
+++ b/src/cl_gt_device.h
@@ -127,7 +127,6 @@ DECL_INFO_STRING(spir_versions, "1.2")
 .partition_property = {0},
 .affinity_domain = 0,
 .partition_type = {0},
-.device_reference_count = 1,
 .image_pitch_alignment = 1,
 .image_base_address_alignment = 4096,
 .cmrt_device = NULL
-- 
1.7.9.5

____________________________________________________________
TRY FREE IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if5
Capture screenshots, upload images, edit and send them to your friends
through IMs, post on Twitter®, Facebook®, MySpace™, LinkedIn® – FAST!




More information about the Beignet mailing list