This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] SK-TDA4VM:使用具有多线程环境的 edgeai-tiovx-apps 运行多图形流水线、该怎么做?

Guru**** 2399305 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1490588/sk-tda4vm-running-the-multi-graph-pipeline-with-edgeai-tiovx-apps-with-multi-threads-environment-how

器件型号:SK-TDA4VM

工具与软件:

 您好、我们已经尝试使用 tiovx 来实现2D 位块传输模块。 为了实现这个目标、

我们已经在 GitHub 存储库上引用了 edgeai-tiovx-apps 软件包的 multi_graph_test.c。 源代码的特定路径如下所示。

https://github.com/TexasInstruments/edgeai-tiovx-apps/blob/develop/tests/app_tiovx_linux_multi_graph_test.c

我们成功地获得了由4个图组成的代码的结果。 (颜色转换-多尺度-马赛克-颜色转换)为精确。

问题是、在源代码内、

这里有几条线

/*
     * Note that in below loop graph on and 2 are running sequentially
     * to run them in parellel, you need to decuple them by creating
     * seperate threads for enqueue/dequeue of each graph
     */
    for (int i = 0; i < APP_NUM_ITERATIONS; i++) {

它们是明确的。 因此、在我看来、为了实现最佳性能、
我们需要以某种方式对 它们解耦、并调用下面每个图形的单独线程中的队列/出队部分。

    /*
     * Note that in below loop graph on and 2 are running sequentially
     * to run them in parellel, you need to decuple them by creating
     * seperate threads for enqueue/dequeue of each graph
     */
    for (int i = 0; i < APP_NUM_ITERATIONS; i++) {
        //Graph1 Execution
        inbuf1 = v4l2_decode_dqueue_buf(v4l2_decode_handle);
        outbuf1 = tiovx_modules_acquire_buf(out_buf_pool1);
        tiovx_modules_enqueue_buf(inbuf1);
        tiovx_modules_enqueue_buf(outbuf1);
        inbuf1 = tiovx_modules_dequeue_buf(in_buf_pool1);
        outbuf1 = tiovx_modules_dequeue_buf(out_buf_pool1);
        v4l2_decode_enqueue_buf(v4l2_decode_handle, inbuf1);

        //Graph2 Execution
        inbuf2 = tiovx_modules_acquire_buf(in_buf_pool2);
        outbuf2 = tiovx_modules_acquire_buf(out_buf_pool2);
        //Swap input2 mem with output1 to feed graph1 out to graph2
        tiovx_modules_buf_swap_mem(outbuf1, inbuf2);
        tiovx_modules_release_buf(outbuf1);
        tiovx_modules_enqueue_buf(inbuf2);
        tiovx_modules_enqueue_buf(outbuf2);
        inbuf2 = tiovx_modules_dequeue_buf(in_buf_pool2);
        outbuf2 = tiovx_modules_dequeue_buf(out_buf_pool2);
        kms_display_render_buf(kms_display_handle, outbuf2);
        tiovx_modules_release_buf(inbuf2);
        tiovx_modules_release_buf(outbuf2);
    }

这是一个问题。
1、"创建独立线程"到底意味着什么?
  API 是否与 pthread 或 std :: thread 兼容/线程安全?

2. openvx 图应该总是用 vx_context 操作,不是吗? 嗯、如果是的话  
  创建几个不同的线程、以使每个图形的数据进入队列/退出队列、如何设置
  我为它管理环境?

3.是否有任何示例/教程/示例代码可以参考以实现多线程
 使用 tiovx 运行多图形的设置?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    许世珍

    1.是的,它与 pthread 兼容

    2.是 openvx 图与上下文关联。 当您使用此 API tiovx_modules_initialize_graph()初始化图形时、它会为它创建上下文、每个图形对象都有自己的上下文、请参阅 GraphObj 结构

    通过调用 API tiovx_modules_clean_graph()并将图形对象作为参数来释放上下文。

    3.请参阅 app_tiovx_linux_multi_capture_display_test.c 文件、该文件具有针对同一图形的 pthread 实现、但可以通过将图形对象作为线程参数传递给多个图形。

    此致、
    Gokul

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    非常感谢您的快速响应。
    我对多线程/多图形方法进行了测试、结果发现它适用于尺寸相对较小的图形、例如我们的用例、
    使用具有单个线程的单个图形似乎具有更高的性能。