Achieving Optimal Performance from C/C++ Source Code
General Guidelines
It is useful to bear in mind the following basic strategy when writing an
application:
1. Try to choose an algorithm that is suited to the architecture being
targeted. For example, there may be a trade-off between memory
usage and algorithm complexity that may be influenced by the tar-
get architecture.
2. Code the algorithm in a simple, high-level generic form. Keep the
target in mind, especially with respect to choices of data types.
3. You can then turn your attention towards code tuning. For critical
code sections, think more carefully about the strengths of the target
platform, and make any non-portable changes where necessary.
Tip: Choose the language as appropriate.
As the programmer your first decision is to choose whether to implement
your application in C or C++. This decision may be influenced by perfor-
mance considerations. C++ code using only C features will have very
similar performance to pure C source. Many higher-level C++ features (for
example those resolved at compile-time, such as namespaces, overloaded
functions and inheritance) have no performance cost. However, use of
some other features may degrade performance, and so the performance
loss must be weighed against the richness of expression available in C++.
Examples of features that may degrade performance are virtual functions
or using classes to implement basic data types.
This section contains:
•
"How the Compiler Can Help" on page 2-4
•
"Data Types" on page 2-7
•
"Getting the Most from IPA" on page 2-9
VisualDSP++ 3.5 C/C++ Compiler and Library Manual
for ADSP-219x DSPs
2-3
Need help?
Do you have a question about the VISUALDSP++ 3.5 and is the answer not in the manual?
Questions and answers