2023年4月14日 09:52,Zhangfei Gao <zhangfei.gao@linaro.org> 写道:

On Wed, 12 Apr 2023 at 14:47, Zhangfei Gao <zhangfei.gao@linaro.org> wrote:

This is only for demo of the adapter proposal
Goals
1. support cpu instruction accelerator
2. support switch between hardware accelerator and cpu instruction

Status
1. Existing hardware accelerator are supported.
2. Add a hisi_zlib driver to simulate cpu instruction, supported by uadk_comp

Todo:
1. how to better coexist with existing wd_xxx_init.
wd_xxx_init is not a must, only required for hardware resources.
On platform only support cpu, wd_xxx_init can be used, but the failure should not be treated as error.

2. how to parse workers from config, or environment.

3. how to switch between hardware and cpu, ie, add policy.
Now only simply add round-robin policy: adapter_roundrobin.c
The plan will add at least adapter_threshold.c, ...


我理解wd_xxx_init / init2都只能加载一个默认硬件驱动,
区别init只能选择硬件加速器,
init2带type,可以选其他类型,
加载多个驱动做不到,也不一定是用户期望的。
比如平台上同时有加速器,指令集,支持gzip,wd_xxx_init是一次性全load,还是根据优先级选最高的,真的帮用户做决定么。

或者说wd_xxx_init只是初始化硬件资源,再加载这个硬件加速器, (这个不是必须的,只有在使用硬件加速器的时候)
而加载其他驱动则有其他api来做。


关于ctx,sched,
根据定义ctx就是硬件资源,sched则是选择ctx。 sess是软件资源。
也就是如果只使用cpu指令集,则ctx, sched可以不选。
所以现在uadk库需要考虑ctx, sched为空的情况。


wd.h

/**

* wd_request_ctx() - Request a communication context from a device.

* @dev: Indicate one device.

*

* Return the handle of related context or NULL otherwise.

*

* The context is communication context between user and hardware. One context

* must be got before doing any task. This function can be used among multiple

* threads. dev should be got from wd_get_accel_list() firstly.

*/

handle_t wd_request_ctx(struct uacce_dev *dev);



wd_alg_common.h

/**

* struct wd_comp_sched - Define a scheduler.

* @name:       Name of this scheduler.

* @sched_policy:   Method for scheduler to perform scheduling

* @sched_init:     inited the scheduler input parameters.

* @pick_next_ctx:  Pick the proper ctx which a request will be sent to.

*          config points to the ctx config; sched_ctx points to

*          scheduler context; req points to the request. Return

*          the proper ctx pos in wd_ctx_config.

*          (fix me: modify req to request?)

* @poll_policy:    Define the polling policy. config points to the ctx

*          config; sched_ctx points to scheduler context; Return

*          number of polled request.

*/

struct wd_sched {

   const char *name;

   int sched_policy;

   handle_t (*sched_init)(handle_t h_sched_ctx, void *sched_param);

   __u32 (*pick_next_ctx)(handle_t h_sched_ctx,

                 void *sched_key,

                 const int sched_mode);

   int (*poll_policy)(handle_t h_sched_ctx, __u32 expect, __u32 *count);

   handle_t h_sched_ctx;

};
_______________________________________________
Acc mailing list -- acc@lists.linaro.org
To unsubscribe send an email to acc-leave@lists.linaro.org