Achieving Optimal Performance from C/C++ Source Code
Examples of the two styles are:
int read_io(int iopg_val) {
int ret_val;
("IOPG=%1 ; %0=IO(0x20);" : "=e"(ret_val) : "e"(iopg_val) : "IOPG");
return ret_val;
}
Bad: uses inline
#include <sysreg.h>
#define ADDR 0x20
int read_io(int iopg_val) {
sysreg_write(sysreg_IOPG, iopg_val);
return sysreg_read(reg_CYCLES);
}
Good: uses
This example reads and returns the
Using Circular Buffers
Circular buffers are often extremely useful in DSP code. They can be used
in several ways. Consider the C code:
for (i=0; i<1000; i++) {
sum += a[i] * b[i%20];
}
Good: the compiler knows that
Clearly the access to array
enabled the compiler will produce a hardware circular buffer instruction
for this access.
Consider the slightly more complicated example:
for (i=0; i<1000; i+=n) {
sum += a[i] * b[i%20];
}
VisualDSP++ 3.5 C/C++ Compiler and Library Manual
for ADSP-219x DSPs
statement.
asm
.
sysreg.h
is a circular buffer. When optimization is
b
register.
CYCLES
is accessed as a circular buffer.
b
2-27
Need help?
Do you have a question about the VISUALDSP++ 3.5 and is the answer not in the manual?
Questions and answers