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

Yang, Rong R rong.r.yang at intel.com
Fri Sep 2 08:07:56 UTC 2016


The patchset LGTM, thanks.

> -----Original Message-----
> From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of
> junyan.he at inbox.com
> Sent: Friday, September 2, 2016 14:38
> To: beignet at lists.freedesktop.org
> Subject: [Beignet] [PATCH 4/11 V2] Runtime: Apply base object to
> cl_device_id
> 
> From: Junyan He <junyan.he at intel.com>
> 
> V2:
>   Fix INIT_ICD, no need for that.
> 
> Signed-off-by: Junyan He <junyan.he at intel.com>
> ---
>  src/cl_device_id.c | 36 +++++++++++++++---------------------
>  src/cl_device_id.h |  8 +++++---
>  src/cl_gt_device.h |  1 -
>  src/cl_khr_icd.h   |  2 --
>  4 files changed, 20 insertions(+), 27 deletions(-)
> 
> diff --git a/src/cl_device_id.c b/src/cl_device_id.c index 08cc0c0..bc130d3
> 100644
> --- a/src/cl_device_id.c
> +++ b/src/cl_device_id.c
> @@ -42,7 +42,6 @@
>  #endif
> 
>  static struct _cl_device_id intel_ivb_gt2_device = {
> -  INIT_ICD(dispatch)
>    .max_compute_unit = 16,
>    .max_thread_per_unit = 8,
>    .sub_slice_count = 2,
> @@ -53,7 +52,6 @@ static struct _cl_device_id intel_ivb_gt2_device = {  };
> 
>  static struct _cl_device_id intel_ivb_gt1_device = {
> -  INIT_ICD(dispatch)
>    .max_compute_unit = 6,
>    .max_thread_per_unit = 6,
>    .sub_slice_count = 1,
> @@ -64,7 +62,6 @@ static struct _cl_device_id intel_ivb_gt1_device = {  };
> 
>  static struct _cl_device_id intel_baytrail_t_device = {
> -  INIT_ICD(dispatch)
>    .max_compute_unit = 4,
>    .max_thread_per_unit = 8,
>    .sub_slice_count = 1,
> @@ -76,7 +73,6 @@ static struct _cl_device_id intel_baytrail_t_device = {
> 
>  /* XXX we clone IVB for HSW now */
>  static struct _cl_device_id intel_hsw_gt1_device = {
> -  INIT_ICD(dispatch)
>    .max_compute_unit = 10,
>    .max_thread_per_unit = 7,
>    .sub_slice_count = 1,
> @@ -87,7 +83,6 @@ static struct _cl_device_id intel_hsw_gt1_device = {  };
> 
>  static struct _cl_device_id intel_hsw_gt2_device = {
> -  INIT_ICD(dispatch)
>    .max_compute_unit = 20,
>    .max_thread_per_unit = 7,
>    .sub_slice_count = 2,
> @@ -98,7 +93,6 @@ static struct _cl_device_id intel_hsw_gt2_device = {  };
> 
>  static struct _cl_device_id intel_hsw_gt3_device = {
> -  INIT_ICD(dispatch)
>    .max_compute_unit = 40,
>    .max_thread_per_unit = 7,
>    .sub_slice_count = 4,
> @@ -110,7 +104,6 @@ static struct _cl_device_id intel_hsw_gt3_device = {
> 
>  /* XXX we clone IVB for HSW now */
>  static struct _cl_device_id intel_brw_gt1_device = {
> -  INIT_ICD(dispatch)
>    .max_compute_unit = 12,
>    .max_thread_per_unit = 7,
>    .sub_slice_count = 2,
> @@ -121,7 +114,6 @@ static struct _cl_device_id intel_brw_gt1_device = {  };
> 
>  static struct _cl_device_id intel_brw_gt2_device = {
> -  INIT_ICD(dispatch)
>    .max_compute_unit = 24,
>    .max_thread_per_unit = 7,
>    .sub_slice_count = 3,
> @@ -132,7 +124,6 @@ static struct _cl_device_id intel_brw_gt2_device = {  };
> 
>  static struct _cl_device_id intel_brw_gt3_device = {
> -  INIT_ICD(dispatch)
>    .max_compute_unit = 48,
>    .max_thread_per_unit = 7,
>    .sub_slice_count = 6,
> @@ -144,7 +135,6 @@ static struct _cl_device_id intel_brw_gt3_device = {
> 
>  //Cherryview has the same pciid, must get the max_compute_unit and
> max_thread_per_unit from drm  static struct _cl_device_id intel_chv_device
> = {
> -  INIT_ICD(dispatch)
>    .max_compute_unit = 8,
>    .max_thread_per_unit = 7,
>    .sub_slice_count = 2,
> @@ -156,7 +146,6 @@ static struct _cl_device_id intel_chv_device = {
> 
>  /* XXX we clone brw now */
>  static struct _cl_device_id intel_skl_gt1_device = {
> -  INIT_ICD(dispatch)
>    .max_compute_unit = 6,
>    .max_thread_per_unit = 7,
>    .sub_slice_count = 2,
> @@ -167,7 +156,6 @@ static struct _cl_device_id intel_skl_gt1_device = {  };
> 
>  static struct _cl_device_id intel_skl_gt2_device = {
> -  INIT_ICD(dispatch)
>    .max_compute_unit = 24,
>    .max_thread_per_unit = 7,
>    .sub_slice_count = 3,
> @@ -178,7 +166,6 @@ static struct _cl_device_id intel_skl_gt2_device = {  };
> 
>  static struct _cl_device_id intel_skl_gt3_device = {
> -  INIT_ICD(dispatch)
>    .max_compute_unit = 48,
>    .max_thread_per_unit = 7,
>    .sub_slice_count = 6,
> @@ -189,7 +176,6 @@ static struct _cl_device_id intel_skl_gt3_device = {  };
> 
>  static struct _cl_device_id intel_skl_gt4_device = {
> -  INIT_ICD(dispatch)
>    .max_compute_unit = 72,
>    .max_thread_per_unit = 7,
>    .sub_slice_count = 9,
> @@ -200,7 +186,6 @@ static struct _cl_device_id intel_skl_gt4_device = {  };
> 
>  static struct _cl_device_id intel_bxt_device = {
> -  INIT_ICD(dispatch)
>    .max_compute_unit = 18,
>    .max_thread_per_unit = 6,
>    .sub_slice_count = 3,
> @@ -211,7 +196,6 @@ static struct _cl_device_id intel_bxt_device = {  };
> 
>  static struct _cl_device_id intel_kbl_gt1_device = {
> -  INIT_ICD(dispatch)
>    .max_compute_unit = 12,
>    .max_thread_per_unit = 7,
>    .sub_slice_count = 2,
> @@ -222,7 +206,6 @@ static struct _cl_device_id intel_kbl_gt1_device = {  };
> 
>  static struct _cl_device_id intel_kbl_gt15_device = {
> -  INIT_ICD(dispatch)
>    .max_compute_unit = 18,
>    .max_thread_per_unit = 7,
>    .sub_slice_count = 3,
> @@ -233,7 +216,6 @@ static struct _cl_device_id intel_kbl_gt15_device = {  };
> 
>  static struct _cl_device_id intel_kbl_gt2_device = {
> -  INIT_ICD(dispatch)
>    .max_compute_unit = 24,
>    .max_thread_per_unit = 7,
>    .sub_slice_count = 3,
> @@ -244,7 +226,6 @@ static struct _cl_device_id intel_kbl_gt2_device = {  };
> 
>  static struct _cl_device_id intel_kbl_gt3_device = {
> -  INIT_ICD(dispatch)
>    .max_compute_unit = 48,
>    .max_thread_per_unit = 7,
>    .sub_slice_count = 6,
> @@ -255,7 +236,6 @@ static struct _cl_device_id intel_kbl_gt3_device = {  };
> 
>  static struct _cl_device_id intel_kbl_gt4_device = {
> -  INIT_ICD(dispatch)
>    .max_compute_unit = 72,
>    .max_thread_per_unit = 7,
>    .sub_slice_count = 9,
> @@ -747,6 +727,7 @@ kbl_gt4_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;
> @@ -1042,10 +1023,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 diff --git
> a/src/cl_khr_icd.h b/src/cl_khr_icd.h index 3985d80..58cee68 100644
> --- a/src/cl_khr_icd.h
> +++ b/src/cl_khr_icd.h
> @@ -21,13 +21,11 @@
> 
>  #define SET_ICD(dispatch) \
>    dispatch = &cl_khr_icd_dispatch;
> -#define INIT_ICD(member)  .member = &cl_khr_icd_dispatch,  #define
> DEFINE_ICD(member) struct _cl_icd_dispatch const *member;
> 
>  extern struct _cl_icd_dispatch const cl_khr_icd_dispatch;  #else  #define
> SET_ICD(dispatch) -#define INIT_ICD(member)  #define
> DEFINE_ICD(member)  #endif
> 
> --
> 2.7.4
> 
> 
> 
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list