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";
}