Hello

How can I use Blackfin 40 bits accumulator.

Can I use it in C, or must I use assembler.

Avinoam

Hello

How can I use Blackfin 40 bits accumulator.

Can I use it in C, or must I use assembler.

Avinoam

Hello

I am adding numbers, 32 bits integers, and the result is bigget than 32 bit. I think it is usefull to use the 40 bit accumulator for such operation. I am not sure how to do this in C. Must I use assembler .

Avinoam Danieli

Hardware Engineer

ITL OPTRONICS

PHONE : 03-9277576 03-9277444

CELL : 054-2889956

Email : avinoam_d@itlasers.com

Address : פתח תקוה 11 גרניט 49002

From: Sean McLemon analog@sgaur.hosted.jivesoftware.com

Sent: Tuesday, April 27, 2010 4:46 PM

To: Avinoam Danieli

Subject: New message: "40 bits accumulator"

<http://ez.analog.com/index.jspa> Analog Devices EngineerZone

40 bits accumulator

reply from Sean <http://ez.analog.com/people/SeanM> McLemon in Blackfin Processors - View the full discussion <http://ez.analog.com/message/9509#9509

Hello

64-bit integers is a good idea. I am worried I will lose performance, because 64-bit integer is not native to blackfin.

Avinoam Danieli

Hardware Engineer

ITL OPTRONICS

PHONE : 03-9277576 03-9277444

CELL : 054-2889956

Email : avinoam_d@itlasers.com

Address : פתח תקוה 11 גרניט 49002

From: stevek analog@sgaur.hosted.jivesoftware.com

Sent: Wednesday, April 28, 2010 10:34 AM

To: Avinoam Danieli

Subject: New message: "40 bits accumulator"

<http://ez.analog.com/index.jspa> Analog Devices EngineerZone

40 bits accumulator

reply from stevek <http://ez.analog.com/people/stevek> in Blackfin Processors - View the full discussion <http://ez.analog.com/message/9523#9523

Hello

I need to calculate variance. I have 16 bit data. Xi * Xi genarates 32 bit data. In order to calculate Sum (Xi * Xi) I need the 40 bits accumulator. I think I need full accuracy in variance calculation, because I subtract to large numbers, and a small rounding error may cause large error.

Avinoam

Hi Avinoam,

Attached a C written variance function that should do what you are after. It does not use the accumulator, however it makes use of 32-bit and 64-bit arithmetic for best accuracy. The function will work for sample sizes of up to 32768. Please be aware that the function does not use saturating arithmetic (as is the default in the fract16 library) and thus sample sizes exceeding the maximum limit can lead to unexpected results. For sample sizes less than 256, the function will be about three times slower than the current function in the runtime library. For larger sample sizes, it will be about twice as slow.

If you are looking for an alternative implementation using the accumulator, there are restrictions in its usefulness you should be aware of:

- the programmer can not explicitly make use of the accumulator in C written programs
- if the sample size exceeds 255 elements, there is a chance that the accumulator might overflow and saturate
- the algorithm requires to compute the square of the sum of the input values divided by the sample length - to perform these operations you will have to extract the data from the accumulator and use 32-bit or 64-bit arithmetic operators instead. Thus the main gain from using the accumulator to compute the sums of the squares would only be improved performance for sample sizes less than 256.

Hope this helps.

AndreasL

- the programmer can not explicitly make use of the accumulator in C written programs
- 1 person found this helpful
We're also improving support for direct access to the accumulators, for the next major release of VisualDSP++, code-named Andromeda, due out next year. We're doing this in a couple of ways.

The first is that we're adding compiler intrinsics that specifically employ the accumulators (rather than it being a side-effect of the compiler optimizing the arithmetic). For example:

acc40 sum = 0;

/* Compute vector dot product for given output */

for (j = min_j; j <= max_j; j++) {

acc40 prod = multr_fr1x32x32(input_x[j], input_y[k - j]);

sum = A_add(sum, prod);

}Here, A_add() is an intrinsic that specifically works with accumulators.

(just like fract16 and fract32, acc40 is just a typedef to an underlying integer type - in this case, to a 64-bit integer so that all 40 bits will fit.)

The second way we're improving support is that we're adding support for Embedded C, so that accum is a native type in C, not just a typedef to an integer. The equivalent code is:

accum sum = 0.0k;

/* Compute vector dot product for given output */

for (j = min_j; j <= max_j; j++) {

sum += input_x[j] * input_y[k - j];

}Since accum is a native type, the multr_fr1x32x32() and A_add() intrinsics are not necessary; += and * just work.

The compiler for VisualDSP++ Andromeda is currently in Beta test. If you're interested in getting an early peek, we can put you in contact with the Beta Programme manager.

steve

Hello

I would like to get a beta version of new compiler.

Until then, can you send me assembler example how to use 40 bit accumulator .

Thank you,

Avinoam Danieli

Hardware Engineer

ITL OPTRONICS

PHONE : 03-9277576 03-9277444

CELL : 054-2889956

Email : avinoam_d@itlasers.com

Address : פתח תקוה 11 גרניט 49002

From: stevek analog@sgaur.hosted.jivesoftware.com

Sent: Tuesday, April 27, 2010 5:10 PM

To: Avinoam Danieli

Subject: New message: "40 bits accumulator"

<http://ez.analog.com/index.jspa> Analog Devices EngineerZone

40 bits accumulator

reply from stevek <http://ez.analog.com/people/stevek> in Blackfin Processors - View the full discussion <http://ez.analog.com/message/9500#9500

Message was edited by: Sean McLemon (defined what I meant by "intrinsic")