|
|
This page example |
|
|
\ No newline at end of file |
|
|
This page contains some advanced guidelines for adding new functionality to the SDK4ED Energy Toolbox
|
|
|
|
|
|
**Guidelines for adding a new device in Energy Consumption Estimation (Static Analysis) component**
|
|
|
|
|
|
In this paragraph some steps that a user has to follow in order to add more embedded platforms in the SDK4ED energy toolbox and more specifically in static energy consumption estimation, are provided.
|
|
|
*Backend*
|
|
|
|
|
|
The main script (main_static_analysis.py) receives as input the source files of an application and performs the energy analysis for all the functions and loop statements. The predictions are based on a set of data collected on a specific platform (as described before).
|
|
|
|
|
|
The script can make predictions for any platform by utilizing the python script energy_estimation.py
|
|
|
|
|
|
The script energy_estimation.py can be executed as follows:
|
|
|
```
|
|
|
python energy_estimation.py <fileout> <data1> <data2> <data3> <storefile>
|
|
|
```
|
|
|
where <fileout> is a random file that contains some temporary data about the source files of the application (useful for debugging), <data1>,<data2> and <data3> are files that contain data collected from a specific platform and <storefile> the file where the results of the energy predictions are stored.
|
|
|
<data2> contains the execution time and energy_consumption of each program in the training set. The execution time and energy_consumption of a specific program differ across platforms so there are different <data2> files for making predictions for each platform. In order for the user to add a new platform, the execution time and the energy consumption of the programs of the training-set in the specific new platform must be computed and included in the <data2> file.
|
|
|
|
|
|
Script main_static_analysis.py calls the script energy_estimation.py with different <data2> files for each platform and the results for every platform are stored in the same file. A new call to the energy_estimation.py with the same arguments and the new <data2> file will be added below the previous calls. Comments in the source code will help the user to find the specific place.
|
|
|
|
|
|
- Step 1: The user collects the data for the new platform and provide an additional call to the script energy_estimation.py, giving the new data as a 3rd argument (<data2>).
|
|
|
|
|
|
The user has to follow the following steps in order to compute the execution time and energy consumption of the training-set applications on new platform.
|
|
|
|
|
|
The user executes the C programs contained in the file training_set.txt on the new platform.
|
|
|
|
|
|
In the specific case that the new platform runs a linux OS, the user can use the provided script calculateexecution.py that can be executed as follows:
|
|
|
```
|
|
|
python calculateexecution.py <input_file> <output_file1> measure_time_energy.py <output_file2>
|
|
|
```
|
|
|
where <input_file> contains the code of the training programs (training_set.txt), <output_file1> is a file in which the source code of the program that is currently executed is stored temporarily, <output_file2> is also a temporary file where the results for one program are stored each time and it may be useful for debugging purposes and measure_time_energy.py is a python script that is used for the calculation of the execution time and the energy consumption of a program. Regarding the time measurement, the script provided by the SDK4ED can work on all Linux platforms. For the energy consumption the user has to add the specific commands or programs needed for the specific platform (data received from external monitors, power monitors installed on the platform, path to specific devices from the device tree etc). If energy sensors are not available this procedure can be ignored, or a user defined estimation (such as a power-delay product) can be given by the user. In case no energy measurements are given, only time estimations for the new platform will be supported. The script calculateexecution.py separates all the programs included in the <input_file> and measures the execution time and energy consumption in each of them by using measure_time_energy.py. All the results are stored in a file with the name time_energy_results.out that is used as a <data2> file (see Step 1).
|
|
|
|
|
|
The script sdk4edselector.py takes as input a set of source files from an application and runs script main_static_analysis.py to all of them. The results of each platform are stored in dictionaries. There is a dictionary for function statements and loops and separate dictionaries per platform.
|
|
|
|
|
|
- Step 2: In order for the user to add an extra platform, two extra dictionaries to store the results are needed to be added. All the dictionaries are stored in a json file that is loaded when a specific event in the main page is triggered. Comments in sdk4edselector.py will guide the user
|
|
|
|
|
|
*Front-end*
|
|
|
|
|
|
For adding the new platform on the Front-end, the file EnergyDashPage.js contains the Energy toolbox page. The prediction results are shown in the static analysis panel and are taken from the json file sent by the back-end services. The user can choose a specific platform from a drop-down list to show the prediction results.
|
|
|
|
|
|
- Step 3: There is a method named updateStaticData where given the name of the platform the prediction results for this platform are loaded into the page. If the user wants to show the results for an additional platform, an additional condition is needed to be added in the method that loads these results, including the name of the platform, which must be the same as it is defined in the back-end. |