[FFmpeg-devel] [PATCH 1/4] libavutil/opencl: add opencl device list APIs 20130409

Wei Gao highgod0401 at gmail.com
Tue Apr 9 15:23:51 CEST 2013


2013/4/9 Michael Niedermayer <michaelni at gmx.at>

> On Tue, Apr 09, 2013 at 04:11:27PM +0800, Wei Gao wrote:
> >
>
> >  opencl.c |  298
> +++++++++++++++++++++++++++++++++------------------------------
> >  opencl.h |   44 +++++++++
> >  2 files changed, 201 insertions(+), 141 deletions(-)
> > b4e23897af2cfec8516fd15e8c32c3d494a22e4c
>  0001-add-opencl-device-list-APIs-20130409.patch
> > From 91f88ac410031e01ad9e79c7430012ec78b286cc Mon Sep 17 00:00:00 2001
> > From: highgod0401 <highgod0401 at gmail.com>
> > Date: Tue, 9 Apr 2013 14:58:35 +0800
> > Subject: [PATCH 1/4] add opencl device list APIs 20130409
> [...]
>
> > diff --git a/libavutil/opencl.h b/libavutil/opencl.h
> > index 6ebde10..1ae65bc 100644
> > --- a/libavutil/opencl.h
> > +++ b/libavutil/opencl.h
> > @@ -39,6 +39,32 @@
> >
> >  #define AV_OPENCL_MAX_KERNEL_NAME_SIZE 150
> >
> > +#define AV_OPENCL_MAX_PLATFORM_NUM 200
> > +
> > +#define AV_OPENCL_MAX_DEVICE_NUM 200
> > +
> > +#define AV_OPENCL_MAX_DEVICE_NAME_SIZE 100
> > +
> > +#define AV_OPENCL_MAX_PLATFORM_NAME_SIZE 100
> > +
>
> > +typedef struct {
> > +    int device_type;
> > +    char device_name[AV_OPENCL_MAX_DEVICE_NAME_SIZE];
> > +    cl_device_id device_id;
> > +} AVOpenCLDeviceNode;
> > +
> > +typedef struct {
> > +    cl_platform_id platform_id;
> > +    char platform_name[AV_OPENCL_MAX_PLATFORM_NAME_SIZE];
> > +    int device_num;
> > +    AVOpenCLDeviceNode device_node[AV_OPENCL_MAX_DEVICE_NUM];
> > +} AVOpenCLPlatformNode;
> > +
> > +typedef struct {
> > +    int platform_num;
> > +    AVOpenCLPlatformNode platform_node[AV_OPENCL_MAX_PLATFORM_NUM];
> > +} AVOpenCLDeviceList;
>
> If you use an array of structures like device_node and platform_node
> as part of the public API then the AVOpenCLPlatformNode and
> AVOpenCLDeviceNode structures cannot be extended later with more
> fields as this would break old code that has not been recompiled.
>
> So depending on if you see the need to ever extend these structures
> a different layout might make sense.
> One possibility is an array of pointers to structs as there the array
> elements dont change size when the struct is extended.
>
Thanks, michaelni, do you mean I should define as follows?

typedef struct {
    cl_platform_id platform_id;
    char platform_name[AV_OPENCL_MAX_PLATFORM_NAME_SIZE];
    int device_num;
    AVOpenCLDeviceNode *device_node;
} AVOpenCLPlatformNode;

typedef struct {
    int platform_num;
   AVOpenCLPlatformNode *platform_node;
} AVOpenCLDeviceList;

>
> [...]
>
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Let us carefully observe those good qualities wherein our enemies excel us
> and endeavor to excel them, by avoiding what is faulty, and imitating what
> is excellent in them. -- Plutarch
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>


More information about the ffmpeg-devel mailing list