Because of the holidays, TI E2E™ design support forum responses will be delayed from Dec. 25 through Jan. 2. Thank you for your patience.

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.

Sample OpenMP configuration file

Other Parts Discussed in Thread: SYSBIOS

This post provides a sample OpenMP configuration file and corresponding Platform file for use with OpenMP runtime 1.1.2.6. In this example, code and data are mapped to DDR memory.

Configuration File

/*
 * Copyright (c) 2012, Texas Instruments Incorporated
 * http://www.ti.com
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * *  Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * *  Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * *  Neither the name of Texas Instruments Incorporated nor the names of
 *    its contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */


/* Configure a Shared Region for the application heap. This region is used
 * for:
 *  - Memory allocations from the application via malloc etc.
 *  - Allocate thread local storage
 *  - Can also be used to allocate the application thread stacks
 *    via the OpenMP.stackRegionId parameter
 */

// APP_HEAPOMP is a memory region described in the platform file (Platform.xdc)
var heapOmpMem = Program.cpu.memoryMap["APP_HEAPOMP"];

// Initialize a Shared Region in the APP_HEAPOMP memory region
// Note: If caching is enabled for this region, the memory range must be
// marked cached + write-through
var SharedRegion = xdc.useModule('ti.sdo.ipc.SharedRegion');
SharedRegion.setEntryMeta( 2,
                           {   base: heapOmpMem.base,
                               len:  heapOmpMem.len,
                               ownerProcId: 0,
                               cacheEnable: true,
                               createHeap: true,
                               isValid: true,
                               name: "heapomp",
                           });


/* Configure and setup HeapOMP. This heap is used to abstract memory allocation
 * before and after Shared Regions are initialized via Ipc_start(). Before
 * Ipc_start(), memory allocations are out of a local heap (HeapMem). The size
 * of this heap is specified by 'localHeapSize'. After Ipc_start(),
 * memory allocations are out of the Shared Region heap. The size of the
 * Shared Region used determines the size of this heap.
 */
var HeapOMP = xdc.useModule('ti.omp.utils.HeapOMP');
HeapOMP.sharedRegionId = 2;
HeapOMP.localHeapSize  = 0x20000;

// Configure the local heap
var HeapMem      = xdc.useModule('ti.sysbios.heaps.HeapMem');
var heapMemParams = new HeapMem.Params();
heapMemParams.size = HeapOMP.localHeapSize;

// Configure HeapOMP
var heapOmpParams = new HeapOMP.Params();
heapOmpParams.localHeap = HeapMem.create(heapMemParams)
heapOmpParams.sRegionId = HeapOMP.sharedRegionId;

// For OpenMP, the defaultHeapInstance must be a HeapOMP - check for this
var Memory       = xdc.useModule('xdc.runtime.Memory');
if (Memory.defaultHeapInstance)
    Program.$logWarning("Memory.defaultHeapInstance already set!", this);

// Create a HeapOMP instance and set it as the default heap
Memory.defaultHeapInstance = HeapOMP.create(heapOmpParams)


/* Configure OpenMP
 * - OpenMP.setNumProcessors configures the number of cores available to
 *   the OpenMP runtime.
 * - OpenMP.stackSize specifies the size of the application stack (one
 *   for each thread)
 * - OpenMP.ipcHeapSize specifies the size of the heap used for
 *     + shared memory allocations from within the OpenMP runtime.
 *     + Allocating OpenMP thread stacks if OpenMP.stackRegionId is 0 (default)
 *   
 */
var OpenMP = xdc.useModule('ti.omp.utils.OpenMP');
OpenMP.setNumProcessors(8);
OpenMP.ipcHeapSize = 0x100000;

// In this example, Shared Region 2 is used for allocating OpenMP application
// stacks
OpenMP.stackRegionId = 2;

// Sets the size of the stack used by each OpenMP thread
OpenMP.stackSize = 0x4000;

/* Configure caching for various memory regions
 * If an OpenMP shared variables resides in cached shared memory (DDR or MSMC),
 * the memory also needs to be marked write-through. The OpenMP runtime
 * relies on this for correctness.
 */
var Cache   = xdc.useModule('ti.sysbios.family.c66.Cache');

// Enable caching for code (DDR3)
var codeMem = Program.cpu.memoryMap[Program.platform.codeMemory];
Cache.setMarMeta(codeMem.base, codeMem.len, Cache.PC);

// Enable caching & writethrough for data (DDR3_DATA)
var dataMem = Program.cpu.memoryMap[Program.platform.dataMemory];
Cache.setMarMeta(dataMem.base, dataMem.len, Cache.PC | Cache.WTE);

// Enable caching & writethrough for application heap
Cache.setMarMeta(heapOmpMem.base, heapOmpMem.len, Cache.PC | Cache.WTE);


/* Miscellaneous configuration options. Refer BIOS documentation for
 * details on these.
 */
var Task = xdc.useModule('ti.sysbios.knl.Task');
Task.deleteTerminatedTasks = true;

var System = xdc.useModule("xdc.runtime.System");
var SysMin = xdc.useModule("xdc.runtime.SysMin");
System.SupportProxy = SysMin;
SysMin.bufSize = 0x8000;

Corresponding Platform.xdc

/*
 * Copyright (c) 2012, Texas Instruments Incorporated
 * http://www.ti.com
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * *  Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * *  Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * *  Neither the name of Texas Instruments Incorporated nor the names of
 *    its contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

metaonly module Platform inherits xdc.platform.IPlatform {

    config ti.platforms.generic.Platform.Instance CPU =
        ti.platforms.generic.Platform.create("CPU", {
            clockRate:      1000,                                       
            catalogName:    "ti.catalog.c6000",
            deviceName:     "TMS320C6678",
            customMemoryMap: [
                ["L2SRAM", 
{name: "L2SRAM",    base: 0x00800000, len: 0x00050000, access: "RW"}],
                ["DDR3",   
{name: "DDR3",      base: 0x80000000, len: 0x01000000, access: "RX"}],
                ["DDR3_DATA",    
{name: "DDR3_DATA",      base: 0x81000000, len: 0x08000000, access: "RW"}],
                ["APP_HEAPOMP",  
{name: "APP_HEAPOMP",    base: 0x89000000, len: 0x10000000, access: "RW"}],
                ["MSMCSRAM",
 {name: "MSMCSRAM",  base: 0x0C000000, len: 0x00100000}],
                ["MSMCSRAM_NOCACHE",
{name: "MSMCSRAM_NOCACHE", base: 0xA0100000, len: 0x00300000}],
            ],
            l1DMode:"32k",
            l1PMode:"32k",
            l2Mode:"128k",
    });
    
instance :
    
    override config string codeMemory  = "DDR3";   
    override config string dataMemory  = "DDR3_DATA";
    override config string stackMemory = "L2SRAM";
}

  • Hi Ajay,

    Can you also update the .cfg file for the image_processing_openMP_evmc6678l inside the latest MCSDK? It still use the same old .cfg file as in the previous version.

    I am a beginner, everytime I create a project, sample projects are my reference and where I starts.

    When I rebuild the project using the latest MCSDK, I couldn't run the .out file. Here is what I've received in my ROV.

    Exception, Address,0xf8f2c728 Decoded,Internal: Fetch packet exception; Resource conflict exception; Exception Context, $addr,0x00834f40 $type,ti.sysbios.family.c64p.Exception.Context A0,0x900040b8 A1,0x900040b8 A10,0x00000002 A11,0xa02532a0 A12,0xb4eca9d4 A13,0x0c0e1ecc A14,0x900040b8 A15,0x00000000 A16,0x900040b8 A17,0x00000000 A18,0x90004078 A19,0x00000040 A2,0x00000000 A20,0x00000180 A21,0x10002a60 A22,0x58b00310 A23,0x0602734c A24,0x2c010400 A25,0x44918804 A26,0x02000000 A27,0x00000000 A28,0x00000008 A29,0x0000000b A3,0x000000fe A30,0x00000002 A31,0xa024205c A4,0xb1f94e96 A5,0x900040b8 A6,0xf8f2c729 A7,0x00000000 A8,0x00000000 A9,0x00000004 AMR,0x00000000 B0,0x00000001 B1,0x00000001 B10,0x90000020 B11,0x00000000 B12,0x00000001 B13,0x0c06b1ec B14,0xa0252000 B15,0x00831ef8 B16,0x00000000 B17,0x00832028 B18,0x000000ff B19,0x00000020 B2,0x00000000 B20,0x00000020 B21,0x00100282 B22,0x21601080 B23,0x00024900 B24,0x98620404 B25,0x30195800 B26,0x00a00440 B27,0xc31811d2 B28,0x48a82808 B29,0x10204002 B3,0x0c068190 B30,0x00000000 B31,0x00000002 B4,0x900040b8 B5,0x0c0e1ecc B6,0x00000000 B7,0x00000001 B8,0x00000000 B9,0x00000001 EFR,0x00000002 IERR,0x00000012 ILC,0x00000000 IRP,0x00000000 ITSR,0x00000000 NRP,0xf8f2c728 NTSR,0x0001000f RILC,0x00000000 SSR,0x00000000

    No problem running the supplied .out, though.

    Thanks.

    Rizuan

  • Rizuan,

    I've forwarded your request to the maintainers of the image processing demo. Thanks for pointing out the issue.

    Ajay

  • Hi,

    When I use your updated .cfg file in the hello example, it has a compiling error:

    Description Resource Path Location Type Cannot read property "base" from undefined omp_config.cfg /openmpHello0 Configuration Validation XDCTools Configuration Marker Cannot read property "base" from undefined (C:/Users/Jeff/workspace_v5_1_OPENMP/openmpHello0/omp_config.cfg#44) omp_config.cfg /openmpHello0 44 C/C++ Problem

    It points to line 44:

      SharedRegion.setEntryMeta( 2,

                                 {   base: heapOmpMem.base,                              

                                     len:  heapOmpMem.len,                              

                                     ownerProcId: 0,

                                     cacheEnable:true,

                                     createHeap:true,

                                     isValid:true,

                                     name:"heapomp",                          

                                  });

                            

    Why the compiler does not know .base? Could you help me? Thanks.

  • Hi Robert,

    Are you using the supplied platform.xdc ? If not, you need to make sure

    var heapOmpMem = Program.cpu.memoryMap["XXXXXX"];

    XXXXXX above is available in your platform.xdc. .base refer to the custom  memory map base.

    Hope this will help.

    Rizuan

  • Ajay,

    How do I use the above xdc file in my omp project? If my understanding is correct, Platform.xdc file is auto-generated from RTSC platform wizard tool. The tool supports import option but expects a path to an existing repository.

    I have been able to get omp projects working on the board with default settings in omp example xdc file but how can I modify the cache sizes and section memory maps?

    Also, can you please point me to existing omp tutorials/documentation that might help me in the same.

    Thank you in advance.

    regards,

    Barath Ramesh

  • Barath,

    This post contains information on using a custom platform file: http://e2e.ti.com/support/development_tools/compiler/f/343/p/228254/805521.aspx#805521

    Ajay