Using ALFRED Prototype¶
To use ALFRED prototype you need to:
Generate the LLVM IR of your program, as we describe in Target Program Compilation
Configure ScEpTIC and your target architecture, as we describe in ScEpTIC Configuration
Configure the energy model of the target MCU, as we describe in Energy Model
Configure ALFRED, as we describe in virtual_memory
Configure the Performance Analysis and/or Memory Usage Analysis
Execute ScEpTIC anaysis, as we describe in Execute ScEpTIC Analysis
Example Configuration for ALFRED¶
We provide here a portion of ScEpTIC configuration file that captures all the parameters introduced by ALFRED. Note that the example below makes ScEpTIC to instrument the program with ratchet checkpoint strategy and then applies ALFRED pipeline.
from ScEpTIC.AST.misc.virtual_memory_enum import VirtualMemoryEnum
from ScEpTIC.emulator.energy.msp430 import MSP430EnergyCalculator
run_energy_measure = True
run_memory_size_measure = True
memory_size_config = {
'double_buffer_for_anomalies': True,
'global_variables_default_memory': VirtualMemoryEnum.NON_VOLATILE,
}
clock_frequency = '8Mhz'
program_configuration = {
'ir_function_prefix': '@', #llvm ir function name prefix
'main_function_name': 'main',
'before_restore_function_name': 'sceptic_before_restore',
'after_restore_function_name': 'sceptic_after_restore',
'before_checkpoint_function_name': 'sceptic_before_checkpoint',
'after_checkpoint_function_name': 'sceptic_after_checkpoint',
'program_transformations': ['ratchet', 'virtual_memory']
}
energy_simulation_config = {
'use_trigger_calls': False,
'trigger_call_to_checkpoint_probability_range': [0, 10, 1],
'simulate_power_failures': True,
'clock_cycles_between_power_failures': 50000,
}
msp430fr5969_datasheet = {
'registers': 10,
'current_consumption': {
'8Mhz': {
'frequency': '8M',
'voltage': '3',
'n_waits': '0',
'I_am_ram': '585u',
'I_am_fram_uni': '1220u',
'I_am_fram': '890u',
'I_am_fram_hit': '0.75',
},
'16Mhz': {
'frequency': '16M',
'voltage': '3',
'n_waits': '1',
'I_am_ram': '1070u',
'I_am_fram_uni': '1845u',
'I_am_fram': '1420u',
'I_am_fram_hit': '0.75',
},
},
'ADC': {
'T_off_on': '100n',
'T_sampling': '1u',
'I_min': '145u',
'I_max': '185u',
'N_init': '3',
'N_off': '1',
'N_transfer_ops': '1',
'I_to_consider': 'min',
},
}
mcu_datasheet = msp430fr5969_datasheet['current_consumption'][clock_frequency]
energy_calculator = MSP430EnergyCalculator(mcu_datasheet, msp430fr5969_datasheet['registers'], msp430fr5969_datasheet['ADC'])
n_min_function = lambda x: energy_calculator.n_min_function(x)
transformation_options = {
"virtual_memory": {
"n_min_function": n_min_function,
"optimize_saved_registers": True,
},
"ratchet": {
"functions_with_outside_frame_accesses": ["function_name"],
"optimize_saved_registers": True,
}
}