This Insense program performs a Fourier transform on an array of 40 integers repeatedly.
/*
*
* Computational stress test by lots of calculations of the fast fourrier
* transform
*/
type stressI is interface()
component stress presents stressI {
data = new integer[40] of 0
constructor() {
}
behaviour {
for j = 0 .. 100 do {
max = 0
ifft(data, data.length)
for i = 0 .. data.length-1 do {
if(data[i] > max) then {
max := data[i]
}
}
}
stop
}
}
/*********************************************************************/
s1 = new stress()
The corresponding nesC program for TinyOS is shown below.
configuration FourrierAppC {
}
implementation {
components MainC, FourrierC;
FourrierC -> MainC.Boot;
}
/**
* Implementation for Fourrier application.
* Repeatedly calculate the fourrier over an array of numbers
**/
module FourrierC @safe() {
uses interface Boot;
}
implementation {
int16_t are[50];
int16_t aim[50];
int max = 0;
void ifft(int16_t xre[], int16_t xim[], uint16_t n);
task void processTask() {
// do work
int i = 0;
int j = 0;
for( ; j < 100 ; j++) {
ifft( are,aim , 40);
for(i = 0 ; i max) {
max = are[i];
}
}
}
post processTask();
}
event void Boot.booted() {
post processTask();
}
}