#NEWLINE# def initialize( self , context ) : #NEWLINE# #INDENT# if ( not available_freqs . device . is_rooted ) : #NEWLINE# #INDENT# raise InstrumentError ( 'The device must be rooted to sweep frequencies' ) #NEWLINE# #UNINDENT# if ( 'userspace' not in self . device . list_available_cluster_governors ( 0 ) ) : #NEWLINE# #INDENT# raise InstrumentError ( "'userspace' cpufreq governor must be enabled" ) #NEWLINE# #UNINDENT# if ( not self . sweeps ) : #NEWLINE# #INDENT# self . sweeps = [ ] #NEWLINE# for core in set ( self . device . core_names ) : #NEWLINE# #INDENT# sweep_spec = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# sweep_spec [ 'cluster' ] = core #NEWLINE# sweep_spec [ 'label' ] = core #NEWLINE# self . sweeps . append ( sweep_spec ) #NEWLINE# #UNINDENT# #UNINDENT# new_specs = [ ] #NEWLINE# old_specs = [ ] #NEWLINE# for job in context . runner . job_queue : #NEWLINE# #INDENT# if ( job . spec not in old_specs ) : #NEWLINE# #INDENT# old_specs . append ( job . spec ) #NEWLINE# #UNINDENT# #UNINDENT# for ( i , sweep_spec ) in enumerate ( self . sweeps ) : #NEWLINE# #INDENT# if ( 'cluster' not in sweep_spec ) : #NEWLINE# #INDENT# raise ConfigError ( 'cluster must be define for all sweeps' ) #NEWLINE# #UNINDENT# if ( caseless_string ( sweep_spec [ 'cluster' ] ) not in self . device . core_names ) : #NEWLINE# #INDENT# raise ConfigError ( 'Only {} cores are present on this device, you specified {}' . format ( ', ' . join ( set ( self . device . core_names ) ) , sweep_spec [ 'cluster' ] ) ) #NEWLINE# #UNINDENT# if ( 'frequencies' not in sweep_spec ) : #NEWLINE# #INDENT# self . device . enable_cpu ( self . device . core_names . index ( sweep_spec [ 'cluster' ] ) ) #NEWLINE# sweep_spec [ 'frequencies' ] = self . device . list_available_core_frequencies ( sweep_spec [ 'cluster' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . device . enable_cpu ( self . device . core_names . index ( sweep_spec [ 'cluster' ] ) ) #NEWLINE# available_freqs = self . device . list_available_core_frequencies ( sweep_spec [ 'cluster' ] ) #NEWLINE# for freq in sweep_spec [ 'frequencies' ] : #NEWLINE# #INDENT# if ( freq not in available_freqs ) : #NEWLINE# #INDENT# raise ConfigError ( 'Frequency {} is not supported by {} cores' . format ( freq , sweep_spec [ 'cluster' ] ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( 'label' not in sweep_spec ) : #NEWLINE# #INDENT# sweep_spec [ 'label' ] = 'sweep{}' . format ( ( i + 1 ) ) #NEWLINE# #UNINDENT# new_specs . extend ( self . get_sweep_workload_specs ( old_specs , sweep_spec , context ) ) #NEWLINE# #UNINDENT# context . config . workload_specs = new_specs #NEWLINE# config_file = os . path . join ( context . host_working_directory , 'run_config.json' ) #NEWLINE# with open ( config_file , 'wb' ) as wfh : #NEWLINE# #INDENT# context . config . serialize ( wfh ) #NEWLINE# #UNINDENT# context . runner . init_queue ( new_specs )