Blackfin execution peculiarity

Started by John Speth April 8, 2006
Hi Group-

My application is running on a Blackfin BF532 mainly collecting
analog signal samples and doing some simple processing on a per-
sample basis. The data rate is 4M SPS so I'm digging for any speed
optimizations I can get. I've observed a situation in which _adding_
lines of code makes the execution time _decrease_!

Here's my code:

#define BUFFER_SIZE 32

static long gBufferIndex = 0L;
static word gBuffer[BUFFER_SIZE];

#pragma optimize_for_speed

void tsmNoHistory(word sample)

// Store the sample to the buffer
gBuffer[gBufferIndex++] = sample;

// Collect enough samples to completely fill the buffer
if(expected_false(gBufferIndex >= BUFFER_SIZE))

gBufferIndex = 0;

// The buffer is filled so point to the next state
gPfnState = tsmWaitForTrigger;



The above function is a state function in a finite state machine that
exhibits the peculiarity. gPfnState is a function pointer that
executes with every sample. tsmWaitForTrigger is the next-state
function that executes after gBuffer gets filled.

Output bit PF5 shows me the time in the function on a scope. My use
of output pin PF3 is there because I accidentally discovered that if
I use the instructions to set and clear PF3, the execution time of
the function decreases (PF5 high time decreases). If I comment out
the PF3 set and clear lines, the execution time increases.

The observation is backwards from my intuition. I'm using some
appropriate optimization hooks (pragma, expected_false) but I'm out
of ideas on how to optimize it further for speed improvement. I'm
concerned that I'm actually fighting the optimizer and that maybe
I've lost control of optimum code execution speed.

I'm using VDSP++. The software is running 100% in internal RAM (no
external memory). All code and data is in internal RAM. The C
startup code is set to using the instruction cache.

Why does my execution speed decrease when I add instructions?

Does anyone have any ideas or insight on how to get control of the
execution speed and optimizer?

Thanks, John Speth.