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.

6678 Multicore operation problem

Other Parts Discussed in Thread: SYSBIOS

I created a multi-core project in a c6678. Generate an executable file. Eight core at the same time to run the. Out file, run the process found very

strange phenomenon, after a series of tests found is a memory conflict. Because I used a lot of dynamic memory application code and eight core at the

same time from a heapmem dynamic application memory will conflict, so I created the eight core heapmem, I think to the eight heapmem were distributed

to eight cores in, ask how to achieve?

var heapMem0Params = new HeapMem.Params();
heapMem0Params.instance.name = "H0";
heapMem0Params.size = 0x2000000//204857600*3/2;
heapMem0Params.align = 8;
heapMem0Params.sectionName = "myHeap0";
Program.global.task0Heap = HeapMem.create(heapMem0Params);
Program.sectMap["myHeap0"] = "DDR2";
//Program.global.INTMEM_HEAP = HeapMem.create(heapMem0Params);
Memory.defaultHeapInstance = Program.global.task0Heap;
//Memory.defaultHeapInstance = Program.global.INTMEM_HEAP;

var heapMem1Params = new HeapMem.Params();
heapMem1Params.instance.name = "H1";
heapMem1Params.size = 0x2000000//204857600*3/2;
heapMem1Params.align = 8;
heapMem1Params.sectionName = "myHeap1";
Program.global.task1Heap = HeapMem.create(heapMem1Params);
Program.sectMap["myHeap1"] = "DDR3";
//Program.global.INTMEM_HEAP = HeapMem.create(heapMem0Params);
Memory.defaultHeapInstance = Program.global.task1Heap;
//Memory.defaultHeapInstance = Program.global.INTMEM_HEAP;

For example, the above I create the two heapmem, how were they are assigned to the first nuclear and a second nuclear.


In short, also is in a single image, a cfg file created eight core heapmem. To this single image download to 0-7 cores, how to each core dynamic

application to locate a heapmen.

  • Hi,
    I am working with BIOS experts to answer this post. Thank you for your patience.
  • Hi,

    First of all, did you mean to put the second heap in DDR3 instead of DDR2? It's fine if you want to, I just want to make sure it is not a typo.

    During runtime, you can use DNUM to determine which core you are on and use that heap. For example,

    #include <xdc/runtime/IHeap.h>
    #include <xdc/runtime/Memory.h>
    #include <ti/sysbios/heaps/HeapMem.h>
    #include <xdc/cfg/global.h>
    Int main()
    {
    Error_Block eb;
    IHeap_Handle myHeap;
    char *buffer;

    extern __cregister volatile unsigned int DNUM;
    if (DNUM == 0) {
    myHeap = HeapMem_Handle_upCast(task0Heap);
    }
    else if (DNUM == 1) {
    myHeap = HeapMem_Handle_upCast(task1Heap);
    }
    else if // etc.

    Error_init(&eb);
    buffer = Memory_alloc(myHeap, 128, 0, &eb);

    System_printf("buffer = 0x%x\n", buffer);

    Note: this approach does not allow you to use the default heap (i.e. "NULL" as the heap) in Memory_alloc(). It does not allow you to use malloc either. Let me know if you are interested in that. You basically assign the default heap in the .cfg as a HeapCallBack and move the DNUM logic into the alloc, free, etc. functions.

    Todd
  • Thank you very much for your prompt reply! Todd.DDR2 is I make a mistake the and so heapmem into DDR3 inside, you provide this method is very good. But it, because of the restriction of the me algorithm, must be to create multiple heapmem is set to the default heap within the core of each different, so you can achieve?
  • I've attached a .cfg that

    - Create two different HeapMem instance (note: the example only does core 0 and core1 but can be easily expanded to all cores).

    - Creates a HeapCallback instance and fills in the callback functions

    - Plugged the HeapCallback instance into the default heap

    0045.app.cfg

    The .c saws

    - Option 1: using DNUM in the application code to use the correct heap

    - Option 2: The callback functions use the DNUM trick to select the correct heap when using the default heap (or malloc)

    /*
     *  ======== main.c ========
     */
    
    #include <stdlib.h>
    
    #include <xdc/std.h>
    
    #include <xdc/runtime/Error.h>
    #include <xdc/runtime/IHeap.h>
    #include <xdc/runtime/Memory.h>
    #include <xdc/runtime/System.h>
    #include <xdc/cfg/Global.h>
    
    #include <ti/sysbios/BIOS.h>
    
    #include <ti/sysbios/knl/Task.h>
    
    /*
     *  ======== getDefaultHeap ========
     *  Helper function to find the default heap for this core
     */
    static IHeap_Handle getDefaultHeap()
    {
    	extern __cregister volatile unsigned int DNUM;
        IHeap_Handle myHeap;
    
        if (DNUM == 0) {
            myHeap = HeapMem_Handle_upCast(task0Heap);
        }
        else if (DNUM == 1) {
            myHeap = HeapMem_Handle_upCast(task1Heap);
        }
    
        return (myHeap);
    }
    
    /*
     *  ======== myInitFxn ========
     */
    UArg myInitFxn(UArg arg)
    {
        /*
         *  This is called during startup (e.g. before main()).
         *  For this application nothing needs to be done here.
         */
    	return (NULL);
    }
    
    /*
     *  ======== myCreateFxn ========
     */
    UArg myCreateFxn(UArg arg)
    {
        /*
         *  This is called when creating a new Callback instance.
         *  For this application nothing needs to be done here.
         */
    	return (NULL);
    }
    
    /*
     *  ======== myDeleteFxn ========
     */
    Void myDeleteFxn(UArg arg)
    {
        /*
         *  This is called when deleting a Callback instance.
         *  For this application nothing needs to be done here.
         */
    }
    
    /*
     *  ======== myAllocFxn ========
     */
    Ptr myAllocFxn(UArg arg, SizeT size, SizeT align)
    {
    	Error_Block eb;
    	IHeap_Handle myHeap = getDefaultHeap();
    
        Error_init(&eb);
        return (Memory_alloc(myHeap, size, align, &eb));
    }
    
    /*
     *  ======== myFreeFxn ========
     */
    Void myFreeFxn(UArg arg, Ptr addr, SizeT size)
    {
    	IHeap_Handle myHeap = getDefaultHeap();
    
        Memory_free(myHeap, addr, size);
    }
    
    /*
     *  ======== myGetStatsFxn ========
     */
    Void myGetStatsFxn(UArg arg, Memory_Stats *stats)
    {
    	IHeap_Handle myHeap = getDefaultHeap();
    
    	Memory_getStats(myHeap, stats);
    }
    
    /*
     *  ======== myIsBlockingFxn ========
     */
    Bool myIsBlockingFxn(UArg arg)
    {
    	IHeap_Handle myHeap = getDefaultHeap();
    
        return (Memory_query(myHeap, Memory_Q_BLOCKING));
    }
    
    /*
     *  ======== main ========
     */
    Int main()
    { 
        Error_Block eb;
        IHeap_Handle myHeap;
        char *buffer;
        extern __cregister volatile unsigned int DNUM;
    
        Error_init(&eb);
    
        /* Option 1: Use DNUM here to find the correct heap for this core */
        if (DNUM == 0) {
        	myHeap = HeapMem_Handle_upCast(task0Heap);
        }
        else if (DNUM == 1) {
        	myHeap = HeapMem_Handle_upCast(task1Heap);
        }
        else {
        	System_abort("Only created the first two heaps in the .cfg...I'm being lazy:)");
        }
    
    
        buffer = Memory_alloc(myHeap, 128, 0, &eb);
        Memory_free(myHeap, buffer, 128);
    
        /*
         *  Option 2: Use the default heap which is the HeapCallback instance
         *  which does the DNUM trick. malloc will use the default heap also.
         */
        buffer = Memory_alloc(NULL, 128, 0, &eb);
        Memory_free(myHeap, buffer, 128);
        buffer = malloc(128);
        free(buffer);
    
        BIOS_start();    /* does not return */
        return(0);
    }