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.

openMP example error with configuration file memory map

Hi,

I am trying to build the example OpenMP program found in the (openmp_dsp_c667x_2_03_01_00) using the guide found (http://downloads.ti.com/mctools/esd/docs/openmp-dsp/building_openmp_app.html). I am having issues when it comes to loading the program on my board. It appears something is wrong with the configuration file for the RTSC project. I am using the supplied (cfg) and source file so I'm uncertain what the error is. Details below.


MCSDK: pdk_c667x_2_0_2

BIOS: bios_6_45_01_29

openMP: openmp_dsp_c667x_2_03_01_00

ipc: ipc_3_43_01_03

Board: TMDSEVM6678LE Rev. 3B

CCS: 6.2.0

Following the guide I was not able to find or use the platform in CCS (ti.runtime.openmp.platforms.evm6678) so I created a new platform with identical memory layout.


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: 0x00060000,                    
                        space: "code/data",
                        access: "RW",
                     }
                ],
                ["OMP_MSMC_NC_VIRT", 
                     {
                        name: "OMP_MSMC_NC_VIRT",
                        base: 0xA0000000,                    
                        len: 0x00020000,                    
                        space: "code/data",
                        access: "RW",
                     }
                ],
                ["OMP_MSMC_NC_PHY", 
                     {
                        name: "OMP_MSMC_NC_PHY",
                        base: 0x0C000000,                    
                        len: 0x00020000,                    
                        space: "code/data",
                        access: "RWX",
                     }
                ],
                ["MSMCSRAM", 
                     {
                        name: "MSMCSRAM",
                        base: 0x0C020000,                    
                        len: 0x003E0000,                    
                        space: "code/data",
                        access: "RWX",
                     }
                ],
                ["DDR3", 
                     {
                        name: "DDR3",
                        base: 0x80000000,                    
                        len: 0x20000000,                    
                        space: "code/data",
                        access: "RWX",
                     }
                ],
           ],
          l2Mode:"128k",
          l1PMode:"32k",
          l1DMode:"32k",

    });
    
instance :
    
    override config string codeMemory  = "MSMCSRAM";   
    override config string dataMemory  = "DDR3";                                
    override config string stackMemory = "L2SRAM";
    
}


I used the supplied (cfg) and source files shown below to build the project.


#include "ti/runtime/openmp/omp.h"
#include <stdio.h>

int main(int argc, char *argv[]) {

	int nthreads, tid;

	/* Fork a team of threads giving them their own copies of variables */
#pragma omp parallel private(nthreads, tid)
	{

		/* Obtain thread number */
		tid = omp_get_thread_num();
		printf("Hello World from thread = %d\n", tid);

		/* Only master thread does this */
		if (tid == 0) {
			nthreads = omp_get_num_threads();
			printf("Number of threads = %d\n", nthreads);
		}

	} /* All threads join master thread and disband */

	return 0;
}

/***************************/
/* SECTION MAPPING         */
/***************************/
var program = xdc.useModule('xdc.cfg.Program');

program.sectMap[".args"]        = new Program.SectionSpec();
program.sectMap[".bss"]         = new Program.SectionSpec();
program.sectMap[".cinit"]       = new Program.SectionSpec();
program.sectMap[".cio"]         = new Program.SectionSpec();
program.sectMap[".const"]       = new Program.SectionSpec();
program.sectMap[".data"]        = new Program.SectionSpec();
program.sectMap[".far"]         = new Program.SectionSpec();
program.sectMap[".fardata"]     = new Program.SectionSpec();
program.sectMap[".neardata"]    = new Program.SectionSpec();
program.sectMap[".rodata"]      = new Program.SectionSpec();
program.sectMap[".stack"]       = new Program.SectionSpec();
program.sectMap[".switch"]      = new Program.SectionSpec();
program.sectMap[".sysmem"]      = new Program.SectionSpec();
program.sectMap[".text"]        = new Program.SectionSpec();
    
// Must place these sections in core local memory 
program.sectMap[".args"].loadSegment        = "L2SRAM";
program.sectMap[".cio"].loadSegment         = "L2SRAM";

// Variables in the following data sections can potentially be 'shared' in
// OpenMP. These sections must be placed in shared memory.
program.sectMap[".bss"].loadSegment         = "DDR3";
program.sectMap[".cinit"].loadSegment       = "DDR3";
program.sectMap[".const"].loadSegment       = "DDR3";
program.sectMap[".data"].loadSegment        = "DDR3";
program.sectMap[".far"].loadSegment         = "DDR3";
program.sectMap[".fardata"].loadSegment     = "DDR3";
program.sectMap[".neardata"].loadSegment    = "DDR3";
program.sectMap[".rodata"].loadSegment      = "DDR3";
program.sectMap[".sysmem"].loadSegment      = "DDR3";

// Code sections shared by cores - place in shared memory to avoid duplication
program.sectMap[".switch"].loadSegment      = program.platform.codeMemory;
program.sectMap[".text"].loadSegment        = program.platform.codeMemory;

// Size the default stack and place it in L2SRAM 
var deviceName = String(Program.cpu.deviceName);
if  (deviceName.search("DRA7XX") == -1) { program.stack = 0x20000; } 
else                                    { program.stack = 0x8000;  }
program.sectMap[".stack"].loadSegment       = "L2SRAM";

// Since there are no arguments passed to main, set .args size to 0
program.argSize = 0;


/********************************/
/* OPENMP RUNTIME CONFIGURATION */
/********************************/

// Include OMP runtime in the build
var ompSettings = xdc.useModule("ti.runtime.openmp.Settings");

// Set to true if the application uses or has dependencies on BIOS components
ompSettings.usingRtsc = true;

if (ompSettings.usingRtsc)
{
    /* Configure OpenMP for BIOS
     * - OpenMP.configureCores(masterCoreId, numberofCoresInRuntime)
     *       Configures the id of the master core and the number of cores
     *       available to the runtime.
     */

    var OpenMP = xdc.useModule('ti.runtime.ompbios.OpenMP');

    // Configure the index of the master core and the number of cores available
    // to the runtime. The cores are contiguous.
    OpenMP.masterCoreIdx = 0;

    // Setup number of cores based on the device
    if      (deviceName.search("DRA7XX") != -1) { OpenMP.numCores = 2; }
    else if (deviceName.search("6670")   != -1) { OpenMP.numCores = 4; }
    else if (deviceName.search("6657")   != -1) { OpenMP.numCores = 2; }
    else                                        { OpenMP.numCores = 8; }

    // Pull in memory ranges described in Platform.xdc to configure the runtime
    var ddr3       = Program.cpu.memoryMap["DDR3"];
    var ddr3_nc    = Program.cpu.memoryMap["DDR3_NC"];
    var msmc       = Program.cpu.memoryMap["MSMCSRAM"];
    var msmcNcVirt = Program.cpu.memoryMap["OMP_MSMC_NC_VIRT"];
    var msmcNcPhy  = Program.cpu.memoryMap["OMP_MSMC_NC_PHY"];

    // Initialize the runtime with memory range information
    if (deviceName.search("DRA7XX") == -1) {
       OpenMP.msmcBase = msmc.base
       OpenMP.msmcSize = msmc.len;

       OpenMP.msmcNoCacheVirtualBase  = msmcNcVirt.base;
       OpenMP.msmcNoCacheVirtualSize  = msmcNcVirt.len;

       OpenMP.msmcNoCachePhysicalBase  = msmcNcPhy.base;
    }
    else
    {
       OpenMP.allocateStackFromHeap = true;
       OpenMP.allocateStackFromHeapSize = 0x010000;

       OpenMP.hasMsmc = false;
       OpenMP.ddrNoCacheBase = ddr3_nc.base;
       OpenMP.ddrNoCacheSize = ddr3_nc.len;
    }

    OpenMP.ddrBase          = ddr3.base;
    OpenMP.ddrSize          = ddr3.len;

    // Configure memory allocation using HeapOMP
    // HeapOMP handles 
    // - Memory allocation requests from BIOS components (core local memory)
    // - Shared memory allocation by utilizing the IPC module to enable 
    //   multiple cores to allocate memory out of the same heap - used by malloc
    if (deviceName.search("DRA7XX") == -1) {
       var HeapOMP = xdc.useModule('ti.runtime.ompbios.HeapOMP');

       // Shared Region 0 must be initialized for IPC 
       var sharedRegionId = 0;

       // Size of the core local heap
       var localHeapSize  = 0x8000;

       // Size of the heap shared by all the cores
       var sharedHeapSize = 0x08000000;

       // Initialize a Shared Region & create a heap in the DDR3 memory region
       var SharedRegion   = xdc.useModule('ti.sdo.ipc.SharedRegion');
       SharedRegion.setEntryMeta( sharedRegionId,
                                  {   base: ddr3.base,
                                      len:  sharedHeapSize,
                                      ownerProcId: OpenMP.masterCoreIdx,
                                      cacheEnable: true,
                                      createHeap: true,
                                      isValid: true,
                                      name: "DDR3_SR0",
                                  });

       // Configure and setup HeapOMP
       HeapOMP.configure(sharedRegionId, localHeapSize);
    }
    else
    {
       OpenMP.useIpcSharedHeap = false;
       OpenMP.allocateLocalHeapSize = 0x8000
       OpenMP.allocateSharedHeapSize = 0x00800000
    }

    
    var Startup = xdc.useModule('xdc.runtime.Startup');
    Startup.lastFxns.$add('&__TI_omp_initialize_rtsc_mode');
}
else
{
    /* Size the heap. It must be placed in shared memory */
    program.heap = sharedHeapSize;
}

The project builds correctly in CCS however when I launch the program I get the following error.

From my reading I understand this error to correlate to something wrong with the linker command file. However as this is a RTSC project it would be a error in the configuration file.

Because I am using the example configuration file I'm not sure what could be the issue. The memory address seems to be something in the ipc shared region in ddr3 (0x80000000). I am not able to spot anything in the configuration file that seems to overlap the memory region. Anyone have any experience with the example code for openMP and the memory mapping? How would I go about remedying this problem? I have also attached my project files for the platform and project. Thanks in advance.

7824.openMPboard.zip