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.

Questions about HeapMemMP

Hello everyone,

(target C6678, CCS 5.5, BIOS 1.25, XDCTools 3.25)

I want to use HeapMemMP as a shared heap between the 8 cores of the C6678.

Questions :

1) How is exactly managed the Heap ? It's my understanding that there are both LOCAL data for each core about the heap AND data about the heap in shared memory ?

2) It's my understanding that I should NOT set "createHeap" to TRUE for the SharedRegion configuration. I'll create the heap with HeapMemMP_create.

3) How does one use HeapMemMP_Handle_upCast ? It is written everywhere in the documentation that only <ti/ipc/HeapMemMP.h> should be included and NOT #include <ti/sdo/ipc/heaps/HeapMemMP.h>

However in <ti/ipc/HeapMemMP.h> there is no HeapMemMP_Handle_upCast function. And if I include #include <ti/sdo/ipc/heaps/HeapMemMP.h> I get errors because well HeapMemMP_create prototype is different between the two header files.

Regards,

Clement

HeapMemMP_Handle_upCast

  • From my tests so far it seems better to :

    a) not use the upCast function but just do a (IHeap_handle) cast to the HeapMemMP handle.

    b) let the Shared Region create the HeapMemMP then no need to play with Create/Open/UpCast functions

    Clement

  • Clement,

    You do not mention IPC but I assume you are using it because you mention HeapMemMP and SharedRegion which only ship with IPC.

    In a typical IPC setup, SharedRegion #0 (SR_0) always has a heap. Your application can acquire the handle to the SR_0 heap and then allocate memory from that heap. You would do this if your intention is to use the same memory with another core. Here is an example.

    #include <xdc/runtime/IHeap.h>
    #include <xdc/runtime/Memory.h>
    #include <ti/ipc/SharedRegion.h>

    IHeap_Handle heap;
    Ptr ptr;

    heap = (IHeap_Handle)SharedRegion_getHeap(0);  // get the heap handle
    ptr = Memory_alloc(heap, 100, 0, NULL);  // allocate memory from heap

    Look in the SharedRegion documentation for more help.

    ipc_3_10_01_11_release_notes.html
    Documentation
    IPC API (html)
    SharedRegion

    In addition to the SR_0 heap, SYS/BIOS will also have a local heap. The local heap is used by your application for memory owned by each core. To allocate from this heap, which is the default heap, you can simply pass NULL to the memory functions.

    ptr = Memory_alloc(NULL, 100, 0, NULL);  // allocate from the local heap

    See the XDCtools documentation for Memory.

    http://rtsc.eclipse.org/cdoc-tip/xdc/runtime/Memory.html

    ~Ramsey

  • Ramsey,

    Thank you for your input.
    Yes I'm familiar with IPC as I use Notify. My SharedRegion for IPC is setup properly as well as the Multiproc module.

    I got the HeapMemMP module working properly too.

    I'm creating two new Shared Regions (ids 1 and 2) for memory allocation in MSMC and DDR3 respectively.

    I want to know

    a) how is managed the HeapMemMP precisely (where is stored data about the heap)

    b) why it isn't possible to create a SharedRegion without a heap, to create one later with HeapMemMP create function.

    Regards,
    Clement

  • Clement,

    There are two parts to a HeapMemMP: 1) the instance object which is allocated from the local SYS/BIOS heap, and 2) the backing store for the actual heap which is allocated from a shared region.

    When a HeapMemMP instance is created, the create parameter will indicate which regionId to use. The create code will allocate the instance object from the local heap, then it will use the heap in the specified regionId to acquire the backing store for the heap. When that same instance is opened from a remote core, the open code will also allocate its local instance object from its local heap, but will then use the same backing store in shared memory for the heap.

    You can create a shared region without a heap (SharedRegion_Entry::createHeap = false) but then SharedRegion_getHeap() will return null. However, there is an undocumented feature where you can specify the address of the heap backing store. Look in ti/sdo/ipc/heaps/HeapMemMP.xdc for sharedAddr. This feature may be removed in the future. Maybe this is what you are looking for.

    ~Ramsey

  • Ramsey,

    Thank you for your answer,

    It's the information I was looking for.

    What I don't get is how the remote core knows which part of the 'backing store' is used or not ? How do they maintain coherency ?
    I think there are also information about the heap in shared memory where cores write and read the state of the 'backing store' region.

    Also when I create a SR without a Heap (not the IPC shared region 0, others), during IPC_start the code goes through every shared region and I get errors saying that there are no heap for the SR 1 and 2.

    I've seen posts about the sharedAddr, I don't think I need it for now.

    Clement

  • Clement,

    The remote core simply needs to know where in shared memory the heap is.  The heap itself in shared memory contains the info on what is used or not used.  The HeapMemMP code maintains cache coherency.

    You shouldn't have to create a heap for every SharedRegion.  I will try it out and post back if this is a bug.

    Judah

  • Judah,

    Ok about the HeapMemMP info.

    For the heap creation for every SharedRegion, I'll try it again on my side with a more robust test that can be easily reproductible or shared.

    Clement