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.

TDA4VM: PSDK-RTOS-J721E/TIDL/IVISION: Parallel execution of algProcess

Part Number: TDA4VM

Hello,

We are working with PSDK-RTOS-J721E 7.01.00.11.

I am attempting to modify the TIDL host emulation to support execution of multiple frames in parallel.

The first thread (e.g., t0) appears to execute properly, but the execution of the second thread (e.g., t1) appears to be stuck inside function TIDLRT_invoke at the following line of code:

    status = algHandle->ivision->algProcess((IVISION_Handle)algHandle,
    &inBufs,&outBufs,(IVISION_InArgs *)&inArgs,(IVISION_OutArgs *)&outArgs);

In the above function signature, all arguments except 'algHandle' are local to TIDLRT_invoke function, and I have taken care of 'algHandle'.

Do IVISION library calls, especially algProcess, support parallel execution from multiple threads?

Thanks and regards.

  • Hello,

    Is there any news on this topic?

    I used a mutex for algProcess execution from two parallel threads, and observed that both threads execute to completion without any trouble. But I am still not able to execute the algProcess calls simultaneously from the two threads without the mutex.

    Thanks and regards.

  • Hi Sagar,

    Multithreading is expected to work. Each thread shall have a separate algHandle.  Could you confirm that you are creating two algorithm instances in this case?

  • Hello Kumar,

    Yes, I can confirm that I am creating two algorithm instances with separate algHandles. The relevant code snippets are pasted below for your reference.

    /*************************** tidl_tb.c ***************************/
    ...
    void* TIDLRT_invoke_mt(void *args)
    {
        ...
        currentArgs = (MTArgs*)args;
        void *handle = currentArgs->handle;
        ...
        //original TIDLRT_invoke function modified to post status via 4th argument
        TIDLRT_invoke(handle, in, out, &ret_status);
        ...
    }
    int32_t tidlMultiInstanceTest(int8_t** configNames, int32_t totalInsts, void * udmaDrvObjPtr, int32_t argc, char** argv, int32_t currConfigIdx)
    {
        ...
        for(configCnt = 0; ((configCnt < totalInsts) && (status == IALG_EOK)); configCnt++)
        {
            ...
            for(k=0; k<2; k++)
            {
                arr_status[k] = TIDLRT_create(&prms, &arr_handle[k]);
                ...
            }
            ...
        }
        for(i = gParams.startFrameIdx; ((i < (gParams.startFrameIdx + gParams.numFrames)) && (status == IALG_EOK)); i++)
        {
            ...
            for(k=0; k<2; k++)
            {
                arr_args[k]->handle = arr_handle[k];
                ...
            }
            ...
            for(k=0; k<2; k++)
            {
                pthread_create(&arr_threads[k], NULL, TIDLRT_invoke_mt, (void*)arr_args[k]);
            }
            for(k=0; k<2; k++)
            {
                pthread_join(arr_threads[k], NULL);
            }
            for(k=0; k<2; k++)
            {
                pthread_detach(arr_threads[k]);
            }
            ...
        }
    }

    Am I missing something here?

    Thanks and regards.

  • Please use the below example to create the multi-instance.

    ti_dl/rt/test/pc/main.c

    the one in below does not use the right library

    ti_dl/test/src/pc_linux/main.c

    BTW, You can also consider using the below simple TIDL-RT based example, this doesn't have many complexities compared to above

    github.com/.../tidlrt_cpp

  • Hello Kumar,

    The underlying issue in my program was the usage of the same memory spaces for the two threads. I thought I had accounted for this, but it turned out that I had not. Once the issue was resolved, the code started working fine.

    I did not try your recent suggestions, since I am constrained to the testbench in the TIDL version specified in my first post on this topic.

    Thank you for your inputs.