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.

#pragma DATA_ALIGN

Hi champions, 

I am trying to use the #pragma DATA_ALIGN()  to align the data on the DSP.  What I am not quite sure is should this #pragma be used inside of the OpenMP #pragma omp target region, a.k.a, on the DSP, or on the ARM? 

I am using a KeyStone II platform, and trying to port some codes from KeyStone I to II. 

The same question as _nassert()?

Thanks

Cheng

  • A follow-up question:

    When I compile the code, The compiler yields a warning info:

    warning: pragma DATA_ALIGN can only be applied to a file level symbol definition, not "d_origx" (declared at line 170)

    d_origx is a pointer to an range of data. The reason I use pointer is to cast the complex to (real, real), so the d_origx is a pointer of real, which points to an array of complex data. 

    Isn't that allowed in DATA_ALIGN? How to work around this issue?

    Thanks

    Cheng

  • Cheng,

    Can you share a snippet of the code where you are adding DATA_ALIGN pragmas?

    Ajay

  • Cheng,

    I saw this issue still outstanding. Would you be able to share a piece of the code to demo the issue please?

    regards,

    David

  • Hi David,

    Sorry I overlooked that question. 

    Attached please find a very simple code that performs vector add on complex data. It represents two errors I found in my code:

    "vecadd_target.c", line 47: warning: pragma DATA_ALIGN can only be applied to a file level symbol definition, not "a" (declared at line 41)
    "vecadd_target.c", line 48: warning: pragma DATA_ALIGN can only be applied to a file level symbol definition, not "b" (declared at line 41)
    "vecadd_target.c", line 49: warning: pragma DATA_ALIGN can only be applied to a file level symbol definition, not "c" (declared at line 41)

    The second error, which I asked in another thread is:

    vecadd_target.int.c:(.text+0x92): undefined reference to `_nassert'

    Thanks

    Cheng2133.vecadd_complex_align.tar.gz

     

  • Hi Cheng,


    The DATA_ALIGN pragma may only be applied to file level variables. The pragma may not be applied to a,b,c since they are defined in the function scope. Currently, all variables that are mapped to a target are aligned to 128 bytes. Therefore a,b and c are each aligned to 128 bytes already so you don't need the DATA_ALIGN pragma.


    On the _nassert issue, generally you may compile code for the host that includes intrinsic function calls, such as _nassert(), by using the host instrinsics library. The dot product example in /usr/share/ti/examples/dotprod illustrates how to do this. The Makefile includes instructions for downloading the host intrinsics package.


    In order to compile your example:

    1. Download and install the c_intrinsics_host_port package from http://processors.wiki.ti.com/index.php/Run_Intrinsics_Code_Anywhere

    2. In vecadd_target.c, include c6xsim/C6xSimulator_type_modifiers.h and assert.h in the host compilation mode. That is, in the declare target region, add

    #ifdef _TMS320C6600

    #include <c6x.h>

    #else

    #include "c6xsim/C6xSimulator_type_modifiers.h"

    #include <assert.h>

    #endif

    Please let me know if this works.

    Regards,

    Dunni

  • Thanks Dunni,

    I installed the host instrincs packages and could successfully compile and run the dotprod program.

    However, for the vecadd program I sent to you, the error is still here. Attached please find the updated version with using the host intrincis. 

    vecadd_target.int.o: In function `__omp_1_vadd_openmp':
    vecadd_target.int.c:(.text+0x94): undefined reference to `_assert'
    vecadd_target.int.c:(.text+0xa6): undefined reference to `_assert'
    vecadd_target.int.c:(.text+0xb8): undefined reference to `_assert'

    Another quick question, per my understanding,  because the vecadd_target.c will be compiled by both arm-gcc and cl6x, using the host intrincis packages is just to "trick" the host compiler and linker that the device libraries are defined somewhere? Or could you briefly explain me how does it work?

    Thanks

    Cheng8270.vecadd_complex_align_v2.tar.gz

  • Hi Cheng,

    The host intrinsics library allows the same version of your code to compile/run in both the DSP and ARM environments by providing implementations for C6000 DSP intrinsics. In the library, _nassert() is simply defined as assert() in the host (ARM, in this case) environment. You can find more details at http://processors.wiki.ti.com/index.php/Run_Intrinsics_Code_Anywhere. A presentation is embedded in the Introduction section of that wiki page.

    Could you please attach the vecadd_target.int.c file? Also, please share what versions of CGT and MCSDK HPC GA you are using.


    Thanks,

    Dunni

  • Thanks, Dunni,

    Sure. Attached Please find the file.  You could also compile and run the packages I sent at your end. The software stacks I am using are the latest version which I just updated last week.

    Cheng1050.vecadd_target.int.c

  • Hi Cheng,

    The issue is that assert.h is being included from the include paths from the DSP compiler instead of the host compiler. This has been resolved. Updated versions of the tools will be released soon and includes this fix.

    For now, you may you may comment out the calls to _nassert() since each mapped variable is aligned to 128 bytes. Once you have the updated tools, you can use _nassert() with the host intrinsics library.

    Thanks,

    Dunni.