[Beignet] [PATCH] Runtime: Add default extension for platforms before BDW.
Yang, Rong R
rong.r.yang at intel.com
Tue Jul 14 01:48:19 PDT 2015
Memcpy is not safe in cl_intel_platform_get_default_extension, but the device extension array size is same as platform's extension array size, will not overflow (has '\0').
Maybe need a MACRO to define these arrays' size.
Will push it later.
> -----Original Message-----
> From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of
> junyan.he at inbox.com
> Sent: Monday, July 13, 2015 23:38
> To: beignet at lists.freedesktop.org
> Cc: Junyan He
> Subject: [Beignet] [PATCH] Runtime: Add default extension for platforms
> before BDW.
>
> From: Junyan He <junyan.he at linux.intel.com>
>
> Signed-off-by: Junyan He <junyan.he at linux.intel.com>
> ---
> src/cl_device_id.c | 4 ++++
> src/cl_extensions.c | 8 ++++++++
> src/cl_extensions.h | 2 ++
> 3 files changed, 14 insertions(+)
>
> diff --git a/src/cl_device_id.c b/src/cl_device_id.c index f995550..f772278
> 100644
> --- a/src/cl_device_id.c
> +++ b/src/cl_device_id.c
> @@ -353,6 +353,7 @@ has_break:
> device->vendor_id = device_id;
> device->platform = cl_get_platform_default();
> ret = device;
> + cl_intel_platform_get_default_extension(ret);
> break;
>
> case PCI_CHIP_IVYBRIDGE_GT1:
> @@ -365,6 +366,7 @@ ivb_gt1_break:
> intel_ivb_gt1_device.vendor_id = device_id;
> intel_ivb_gt1_device.platform = cl_get_platform_default();
> ret = &intel_ivb_gt1_device;
> + cl_intel_platform_get_default_extension(ret);
> break;
>
> case PCI_CHIP_IVYBRIDGE_GT2:
> @@ -377,6 +379,7 @@ ivb_gt2_break:
> intel_ivb_gt2_device.vendor_id = device_id;
> intel_ivb_gt2_device.platform = cl_get_platform_default();
> ret = &intel_ivb_gt2_device;
> + cl_intel_platform_get_default_extension(ret);
> break;
>
> case PCI_CHIP_BAYTRAIL_T:
> @@ -385,6 +388,7 @@ baytrail_t_device_break:
> intel_baytrail_t_device.vendor_id = device_id;
> intel_baytrail_t_device.platform = cl_get_platform_default();
> ret = &intel_baytrail_t_device;
> + cl_intel_platform_get_default_extension(ret);
> break;
>
> case PCI_CHIP_BROADWLL_M_GT1:
> diff --git a/src/cl_extensions.c b/src/cl_extensions.c index a34aaca..3eb303f
> 100644
> --- a/src/cl_extensions.c
> +++ b/src/cl_extensions.c
> @@ -94,6 +94,14 @@ process_extension_str(cl_extensions_t *extensions)
> }
> }
>
> +LOCAL void
> +cl_intel_platform_get_default_extension(cl_device_id device) {
> + cl_platform_id pf = device->platform;
> + memcpy((char*)device->extensions,
> + pf->internal_extensions->ext_str, sizeof(device->extensions));
> + device->extensions_sz = strlen(pf->internal_extensions->ext_str) + 1;
> +}
>
> LOCAL void
> cl_intel_platform_enable_fp16_extension(cl_device_id device) diff --git
> a/src/cl_extensions.h b/src/cl_extensions.h index 426986c..b4544e2 100644
> --- a/src/cl_extensions.h
> +++ b/src/cl_extensions.h
> @@ -96,3 +96,5 @@ extern void
> cl_intel_platform_extension_init(cl_platform_id intel_platform); extern
> void cl_intel_platform_enable_fp16_extension(cl_device_id device);
> +extern void
> +cl_intel_platform_get_default_extension(cl_device_id device);
> --
> 1.7.9.5
>
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list