SPRUIG6K January 2018 – March 2024
The following is a sample program that can be compiled using both Host Emulation and the C7000 compiler interchangeably without modification to the source. A sample compiler command is provided for each case.
The C7000 compiler (cl7x) command-line options are not compatible with the Host Emulation compilers.
/* Example Program test.cpp */
#include "c7x.h"
extern void test(int8 v);
int main()
{
int8 vec1 = int8(1,2,3,4,5,6,7,8);
int8 vec2 = (int8)5;
test(vec1 + vec2);
}
C7100 Host Emulation compiler command (Linux):
g++ -c --std=c++14 -fno-strict-aliasing -I<cgt_install_path>/host_emulation/include/C7100
test.cpp -L<cgt_install_path>/host_emulation -lC7100-host-emulation
The -fno-strict-aliasing command-line option should always be used with g++ when using Host Emulation. This option ensures the g++ compiler does not use type differences to make aliasing decisions. The Host Emulation implementation uses differing types in order to implement TI vector types. Therefore if this option isn't used, g++ may incorrectly optimize TI vector code utilizing the Host Emulation feature, which may lead to unexpected and incorrect results.
C7000 compiler command:
cl7x test.cpp