# Atmel Software Framework

Benchmark Helper Script

This script is used to workbench a program, without any intervention. Once it is well configured, it will automatically compile the program to evaluate, download it into the target, retrieves the data and computes them to extract the error information. It will store into an output file the cycle count this process took, the duration in seconds, the error average and the maximal error of the results.

To make this script works you will need a serial cable that you have to connect to the port COM1 of you PC. The other end of this cable has to be connected on the USART of the target.
To configure this script, edit the file “benchmark” and modify the values of the variables defines in the section “BENCH CONFIG”.

You will need Data Get and group_dsplib_dataextract plus various standard UNIX tools.

# Configuration

## Constants

This is the definition of the constants used in the header file generated by this script in order to configure the C program to workbench.

• param1_def, param2_def, param3_def, param4_def: These variables contain the names of the constants. for example: 'VECT2_SIZE'
• param1, param2, param3, param4: These variables are defined by a list containing the values of the actual parameters (param1_def, param2_def, param3_def and param4_def). The values of the list are separated by the character ‘::’. If the value has to be a blank, use the special string ‘SPACE’ to specify this case.
Warning
All the parameters have to be used. For example: '32#64#128#256'

## Program

This is the definition of the parameters that permit computations according to the actual configuration of the C program.

• SCRIPT_ERROR_FILE_PATH: Specify the path of the Scilab script used to generate the reference output signal of the C program in order to calculate the error (from the $CUR_PATH directory). For example: "pwd/RESSOURCES/ref_conv.sce" ## Program's location Specify the programs’ path from the$CUR_PATH directory.

• DATAGET: Specify the path of the DataGet application. For example: "pwd/../../SOURCES/WINDOWS/DATA_GET/DataGet.exe"
• DATAEXTRACT: Specify the path of the DataExtract application. For example:"pwd/../../SOURCES/WINDOWS/DATA_EXTRACT/DataExtract.exe"
• SCILAB_PATH: Specify the path of the Scilab directory. For example: '/cygdrive/c/Program Files/scilab-4.1'

./benchmark

# C Program File Pattern

In order to make the script compatible with the C program, you should use this C program pattern to design your benchmark. This pattern works perfectly with the EVK1100 board.

#include <avr32/io.h>
#include "compiler.h"
#include "board.h"
#include "dsp.h"
#include "pm.h"
#include "count.h"
#include "bench_config.h"
int main(int argc, char *argv[])
{
unsigned int cycle_count;
// Switch to external Oscillator 0.
pm_switch_to_osc0(&AVR32_PM, FOSC0, OSC0_STARTUP);
// Initialize the DSP debug module
// Get the actual cycle count
cycle_count = Get_sys_count();
// <<< Type here the code you need to workbench >>>
// Calculate the number of cycles
cycle_count = Get_sys_count() - cycle_count;
// Print the number of cycles
dsp16_debug_printf("Cycle count: %d\n", cycle_count);
// Print the output
// <<< use the functions dsp16_debug_print_vect, dsp32_debug_print_vect, dsp16_debug_print_complex_vect or
while(1);
}

In this program you will have access to the constants you defined in the script file as parameters. Those constants are accessible by including the file “bench_config.h”. Finally the program has to be compiled defining DSP_BENCH=1 and DSP_DEBUG=1.

# The Scilab data comparison script

This is the file that contains the reference signal which should be the result of the output of the program to workbench. It serves to compare this reference signal with the actual output and permits to retrieve the error average and the maximal error of this output signal.
In this file you will just have to generate the signal you should receive with you C program. To do that you will have access to the constants you defined in the script file as parameters. The output signal must be store in the “y” variable and can be a real or a imaginary vector.
Here is an example for the FFT:

y_size = 2^NLOG;
t = 0:(y_size-1);
vect2_input = sin(2*%pi*4000*t/40000);
y = fft(vect2_input)/y_size;

# The output

The resulting file of this benchmark is a text file containing all the workbench results. Each result is printed on 4 lines: the first line corresponds to the cycle count of the process, the next one is the duration of this process in second, the third is the error average of the result and the last, its maximal error. Then you can easily manage such a file using a spreadsheet.

# Troubleshooting

## The HyperTerminal is opened and so the application DataGet cannot open the COM port.

Close the HyperTerminal and rerun the script.

## An error is generated by the Scilab data comparison script.

Check the error on the file “dsp_bench_temp” else try to launch this script manually with the required files.

## An error occurred while compiling the program.

This might be due to an error on your C files. Compile it separately to check the error or look at the file ./dsp_bench_log.txt.

# Information

All the files related to this module are located under /avr32/services/dsp/dsplib/utils/scripts/benchmark