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.

RTOS/TMS320C6678: OpenMP can not work with POSIX Threads

Part Number: TMS320C6678


Tool/software: TI-RTOS

This was my question(i asked before):

Dear all:

when I follow the user guide(downloads.ti.com/.../index.html) to create OpenMP project , I found when I selected "Enable support for OpenMP 3.0" ,it will automaticlly selected "Muli-threading is assumed"(Build->Advanced options ->Advanced Optimizations). The problem is that when "Muli-threading is assumed" is selected , I can't use POSIX Threads. The project can build correctly, however it will die in _c_int00() when it run. Can you tell me the solution to the problem.

Thanks and best regards.

/***************************************************

TI expert @ 's  answer:

Hi qq,


The OpenMP runtime is not built on top of posix threads.  In fact, the default configuration of the OpenMP runtime does not start BIOS running.  You have to modify the boot code to start up BIOS and then run the master thread and the worker threads each on their own cores inside a BIOS task or a pthread.  For example see the following file:

args_main_rtsc.c

In addition, each DSP Core is running it's own version of BIOS.  It is not SMP across all the cores.  The OpenMP runtime manages the synchronization of the threads across the different cores.  So, don't expect the pthread API to work across threads running on different cores.

When you use the --openmp switch the compiler by default includes the multi-threaded version of the RTS library.

When I enabled posix support in the config file via Posix = xdc.useModule('ti.sysbios.posix.Settings') I saw the same crash you were reporting.  There was a bug in one of the RTS files. I've attached a fixed version here:

_mutex.c

You need to modify the linker command file (or rebuild the RTS library with this new file) to place the .far section from this file in L2SRAM.

    .localfar :
    {
        "*rts*.lib" (.far)
        "*rts*.lib" (.fardata)
        "*_mutex.*" (.far)
        "*_mutex.*" (.fardata)
        "ti.drv.qmss*.ae66" (.far:local)
        "omp_config_pe66.oe66" (.far)
        "omp_config_pe66.oe66" (.fardata)

    } > L2SRAM

In addition there was an issue with the OpenMP runtime calling getenv before args_main() is called (it would occur outside of a pthread).  You can work around that by disabling the getenv() routine:

getenv.c

I will submit bug reports for these problems.  I hope this information can get your project working.

Best regards, Eric

/**********************************************************

I just want to know the bug whether have fixed or not, and if have been fixed ,in which release version.

Thank you! Best regards!