SPRUIG3C January 2018 – August 2019 TDA4VM , TDA4VM-Q1
On EVE, the vcc-arp32 tool translates a kernel to
a C source file that contains the five functions described in Chapter 2, which is then compiled by the ARP32 compiler. The vloops()
function contains VCOP intrinsics to implement the vector loop command(s).
On C7x, the vcc7x tool translates a kernel to C++ source file that contains the same five functions, which is then compiled by the C7x compiler.
It is feasible to use this translated output as the basis for additional development or performance optimization by directly modifying the generated code. Under this scenario, translation is a one-time step and the generated code becomes the source code. However, it’s important to be aware of the limitations described in this section. Whether a user chooses to modify the translated output as the basis for further development is up to the user.
Both versions of VCC invoke the C preprocessor on
the Kernel-C input, which removes comments, handles preprocessor directives like
#if
and #include
, and expands macros. The
implication is that the C/C++ output of the migration tool will have these elements
removed, with the exception of VCOP_SIMD_WIDTH
. (Additionally,
VCOP_SIMD_WIDTH
will not be expanded in #if statements.) The
translated output will therefore be less readable and less configurable than the
source.
The migration tool makes some effort to make the translated output resemble the original Kernel-C source code. In particular:
VCOP vectors are translated using “native vector
types” on C7x, which are built-in types in the C7x C Compiler that are declared
using OpenCL™ syntax. The typedef
__vector
maps to an OpenCL type corresponding to a VCOP
vector.
The virtual machine is implemented in C++ using template functions and classes, allowing for a relatively economical yet efficient implementation. Since the virtual machine API is a C++ API, the generated kernel is a C++ source file and must be compiled as C++.
The virtual machine uses extensions to the C++ language, particularly native vector types and C7x intrinsics, and will therefore not be portable to other targets. In particular, the code will not compile and run on a PC or other GPP host.
Although the translated code is C++, the client
code that calls it can be either C or C++. By default, the client code is assumed to
be C and the migration tool includes extern C
on the generate
kernel functions (which are C++) so they are callable from C. If the
--cpp_out
option is used on the migration tool, the client code
is assumed to be C++ and the extern C
declarations are omitted.