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.

Compiler/TDA2PXEVM: TDA2PXEVM

Part Number: TDA2PXEVM

Tool/software: TI C/C++ Compiler

I have written test app (.c) from where VCOP kernel (.k) calls are being invoked for 2d array addition. The code is programmed for EVE core. 

On testing the above code with host emulation (compiled using g++ 5.4.0), everything works fine. But when I test the same code compiled using g++ 7.5 compiler, it is throwing segmentation fault on line where data is being loaded to vector register i.e., Vin1  = in1_ptr[Addr];  Please suggest the solution for the issue.

  • We would need to be able to reproduce the issue to be able to guide you in a solution. Can you provide a source code example that exhibits the segmentation fault?


  • Below code is test_app.c
    #include<stdint.h> //#include<iostream> #include <assert.h> #if VCOP_HOST_EMULATION //Only incase of host emulation #include "sample_vcop_array_add_uns_short_kernel.k" #else #include <vcop.h> using namespace std; extern "C" { void sample_eve_array_add_uns_short(__vptr_uint16 in_arr1, __vptr_uint16 in_arr2, __vptr_uint16 out_arr, unsigned short w, unsigned short h ); } #endif #define SIZE 32 #pragma DATA_SECTION("Adata") uint16_t array1[SIZE] = {1,2,4,5,6,7,8,9,4,5,6,1,2,3,4,5,7,8,9,4,5,6,1,2,1,4,7,8,9,6,5,2}; #pragma DATA_SECTION ("Bdata") uint16_t array2[SIZE] = {1,2,4,5,6,7,8,9,4,5,6,1,2,3,4,5,7,8,9,4,5,6,1,2,1,4,7,8,9,6,5,2}; #pragma DATA_SECTION ("Cdata") uint16_t sum_array[SIZE] = {0}; const unsigned short width = 8; const unsigned short height = 4; #if !(VCOP_HOST_EMULATION) #endif int main() { sample_eve_array_add_uns_short(array1, array2, sum_array, width, height); //Kernel call #if VCOP_HOST_EMULATION for (int i=0;i<SIZE;i++) //std::cout<<" "<<array1[i]<<" + "<<array2[i]<<" = "<<sum_array[i]<<std::endl; #endif return 0; }

    Below code is kernel_code.k

    #if VCOP_HOST_EMULATION
    #include<vcop.h>
    #include<iostream>
    #endif
    
    #define ELEMSZ           sizeof(*in1_ptr)
    #define VECTORSZ        (VCOP_SIMD_WIDTH*ELEMSZ)
    
    void sample_eve_array_add_uns_short
    (
       __vptr_uint16  in1_ptr,         // input 1 data pointer
       __vptr_uint16  in2_ptr,         // input 2 data pointer
       __vptr_uint16  optr,            // output data pointer
       unsigned short width,           // width of each line
       unsigned short height          // height of each line
    )
    {
       __vector Vin1;                 // input1
       __vector Vin2;                 // input2
       __vector Vout;                 // output
    
       
      for (int I1 = 0; I1 < height; I1++)
       {
          
           for (int I2 = 0; I2 < width/VCOP_SIMD_WIDTH; I2++)
           {
              
              __agen Addr;
              Addr = I1*width*ELEMSZ + I2*VECTORSZ;
    
              Vin1     = in1_ptr[Addr];
              Vin2     = in2_ptr[Addr];
              Vout     = Vin1 + Vin2;
              optr[Addr] = Vout;
               
    
           }
       }
    }
    

    Thank you.

  • Were you able to reproduce the issue?

  • Tejashwini N said:
    compiled using g++ 5.4.0

    GCC 5.1.0 < 6.1.0 : libstdc++.so.6.0.21
    GCC 5.1.0 < 6.1.0 : GLIBCXX_3.4.21, CXXABI_1.3.9

    Tejashwini N said:
    compiled using g++ 7.5

    GCC 7.2.0 < 8.1.0 : libstdc++.so.6.0.24
    GCC 7.2.0 < 8.1.0 : GLIBCXX_3.4.24, CXXABI_1.3.11

    Looks like an ABI version issue.

  • I was not able to reproduce the issue.

    > ./linux/bin/g++ --version
    g++ (GCC) 7.5.0
    Copyright (C) 2017 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    
    > ./linux/bin/g++ -DVCOP_HOST_EMULATION a.c
    > ./a.out
     1 + 1 = 2
     2 + 2 = 4
    ...
    
    > ldd a.out
    	linux-vdso.so.1 =>  (0x00007fff33dda000)
    	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f27a0cbb000)
    	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f27a09b5000)
    	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f27a079d000)
    	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f27a03d4000)
    	/lib64/ld-linux-x86-64.so.2 (0x00007f27a1005000)
    

    I also ran the resulting program using GCC's sanitizers for undefined behavior and address checking, and there were no hits on problems that could cause a segmentation fault.

    I took the entire program and ran g++-7.5.0 on it with the online "Compiler Explorer" here: https://godbolt.org/z/GE3jh7

    This utilizes the most recent vcop_host_emulation.h we ship. Is that the one you're using?