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.

C6678 DSP NaN on float-point number

Hi,

I was running some calculations on C6678 DSPs of KS II. But small data size, the result goes correctly. But I found that for some larger data, (which is still less than 32 MB), the results become NaN. 

Do youhave any hints on that?

Thanks

Cheng

  • The info is very vague. How the program looks like, what TI package is used, what memory region of DSP running it? How DSP returns NaN, you mean some garbage value?

    Regards, Eric

  • Hi Eric,

    Thanks for your reply!!

    The code looks like:

    for (int i = 0; i < n; i++) {

        c[i] =  a[i] * b[i];

    }

    All arrays of a, b, and c are float-float numbers.  a[i] and b[i] are initialized between 0 and 1 randomly. c[i]  is initialized as 0. The size of n could be as large as 688128 or even larger. 

    Besides the NaN results when I checked in the array c, I also got +inf ... I guess it might be because of overflow??

  • How do you allocate the array? It is declared as static or use malloc? Maybe you can show us the CCS project we can check?

    Regards, Eric

  • Hi, Eric,

    I allocated the memory statically. 

    After checking the stack size, the stack size was indeed less than the allocated memory. 

    Here is the way I allocated memory globally outside any functions.

    281 #pragma DATA_SECTION(x_sampt_orig, ".ddr")
    284 #pragma DATA_SECTION(origx, ".ddr")
    286 #pragma DATA_SECTION(ftime, ".ddr")


    287 complex_t x_sampt_orig[MAX_B];
    290 complex_t origx[MAX_n];
    292 complex_t ftime[MAX_n];

    294 #pragma DATA_ALIGN(x_sampt_orig, 128)
    297 #pragma DATA_ALIGN(origx, 128)
    298 #pragma DATA_ALIGN(ftime, 128)

    And the linker command

    15 -stack 0x8000000
    16 -heap 0x8000000
    17
    18 MEMORY
    19 {
    20 LOCAL_L2_SRAM: origin = 0x00800000 length = 0x00100000 /* 1MB LOCAL L2/SRAM */
    21 LOCAL_L1P_SRAM: origin = 0x00E00000 length = 0x00008000 /* 32kB LOCAL L1P/SRAM */
    22 LOCAL_L1D_SRAM: origin = 0x00F00000 length = 0x00008000 /* 32kB LOCAL L1D/SRAM */
    23 SHRAM: origin = 0x0C000000 length = 0x00600000 /* 6MB Multicore shared Memmory */
    24
    25 EMIF16_CS2: origin = 0x30000000 length = 0x04000000 /* 64MB EMIF16 CS2 Data Memory */
    26 EMIF16_CS3: origin = 0x34000000 length = 0x04000000 /* 64MB EMIF16 CS3 Data Memory */
    27 EMIF16_CS4: origin = 0x38000000 length = 0x04000000 /* 64MB EMIF16 CS4 Data Memory */
    28 EMIF16_CS5: origin = 0x3C000000 length = 0x04000000 /* 64MB EMIF16 CS5 Data Memory */
    29
    30 DDR3: origin = 0x80000000 length = 0x20000000 /* 2GB CE0 and CE1 external DDR3 SDRAM */
    31 }
    32
    33 SECTIONS
    34 {
    35 .text > DDR3
    36 .stack > DDR3
    37 .bss > DDR3
    38 .cio > DDR3
    39 .const > DDR3
    40 .data > DDR3
    41 .switch > DDR3
    42 .sysmem > DDR3
    43 .far > DDR3
    44 .args > DDR3
    45 .ppinfo > DDR3
    46 .ppdata > DDR3
    47
    48 .pinit > DDR3
    49 .cinit > DDR3
    50
    51 .binit > DDR3
    52 .init_array > DDR3
    53 .neardata > DDR3
    54 .fardata > DDR3
    55 .rodata > DDR3
    56 .c6xabi.exidx > DDR3
    57 .c6xabi.extab > DDR3
    58
    59 .l1sram > LOCAL_L1D_SRAM
    60 .ddr > DDR3
    61 .l2sram > LOCAL_L2_SRAM
    62 }

    I set the stack and heap size as 128 MB, which I think is way of greater than the allocated memory. 

    The problems of NaN and Inf seems go away, but come with the following errors:

    ERROR: x_sampt[973].re: 0.000000 (orig) != -0.001658 (opt)
    ERROR: x_sampt[973].im: 0.000000 (orig) != 0.000475 (opt)
    cpu opt: 2 Errors
    ERROR: x_sampt[2].im: 64357.824219 (orig) != 15312665706496.002674 (opt)
    ERROR: x_sampt[110].re: 0.000000 (orig) != -0.000000 (opt)

    Do you have any hints?

    Thanks

    Cheng