def collect_online_window_based(current_run_period, benchmark_dir, ncore, freq_w): #during sniper runTime W_P = UL.get_window_past() window_based_feature_list = [] feature_list = [] for w in range(W_P): feature_list.append([]) for w in range(W_P): print("frequency[%s][0]= %s" % (w, freq_w[w][0])) #current_feature_list=get_stats(current_run_period,benchmark_dir,ncore,'ONLINE',freq_w[W-P-1],freq[W-P-1])#actually one of the freq_w is necessary for w in reversed(range(W_P)): offset = W_P - 1 - w if current_run_period - offset >= 1: print("freq_w[%s] in collect_online_window_based: %s\n" % (w, freq_w[w])) feature_list[w] = get_stats(current_run_period - offset, benchmark_dir, ncore, 'ONLINE', freq_w[w], freq_w[w]) last_feature_list = feature_list[w] else: feature_list[w] = last_feature_list for w in range(W_P): window_based_feature_list += feature_list[w] return window_based_feature_list
def collect_offline_window_based(input_dir,input_filename,output_dir,output_filename,collect_mode): #collects the stats from sqlite files generated earlier W_P=UL.get_window_past() #Window for Past sequences #TODO W_F=1 #UL.get_window_future() #Window for Future sequences # currently 1 step forward prediction, because the DNN just has one output Rfile_read_freq = file(os.path.join(input_dir, input_filename), 'r') Wfile_features_labels = file(os.path.join(output_dir,output_filename), 'a') feature_list = [] for w in range(0,W_P): feature_list.append([]) line_count=-1 for line in Rfile_read_freq: line_splitted = line.split('\t') line_count+=1 if (line_count==0): num_core = int(line_splitted[0]) if (line_count>W_P): if (collect_mode=='CORE_BASED'): for w in reversed(range(0,W_P)): feature_list[W_P-1-w],labels = get_stats(line_count-w,input_dir,num_core,'OFFLINE',line_splitted) if (w==0):#current features old_labels=labels try:#TODO for W_F > 1 feature_list_trash,labels = get_stats(line_count+(W_F),input_dir,num_core,'OFFLINE',line_splitted) old_labels=labels except: labels=old_labels for core in range(num_core): for w in range(0,W_P): for f in feature_list[w]: Wfile_features_labels.write('%s,'%f[core]) Wfile_features_labels.write('%s\n'%labels[core]) #for w in (range(0,W_F-1)): # try: # feature_list_trash,labels = get_stats(line_count+(w+1),input_dir,num_core,'OFFLINE',line_splitted) # Wfile_features_labels.write('%s,'%labels[core]) # old_labels=labels # except: # Wfile_features_labels.write('%s,'%old_labels[core]) #this version just works for W_F=1 #try: # feature_list_trash,labels = get_stats(line_count+(W_F),input_dir,num_core,'OFFLINE',line_splitted) # Wfile_features_labels.write('%s\n'%labels[core]) #except: # Wfile_features_labels.write('%s\n'%old_labels[core]) Rfile_read_freq.close() Wfile_features_labels.close()
def collect_online_window_based(current_run_period,benchmark_dir,ncore,freq): #during sniper runTime W_P=UL.get_window_past() window_based_feature_list = [] feature_list=[] for w in range (W_P): feature_list.append([]) current_feature_list=get_stats(current_run_period,benchmark_dir,ncore,'ONLINE',freq) for w in reversed(range (W_P)): offset=W_P-1-w if current_run_period-offset>=1: feature_list[w]=get_stats(current_run_period-offset,benchmark_dir,ncore,'ONLINE',freq) last_feature_list = feature_list[w] else: feature_list[w]= last_feature_list for w in range (W_P): window_based_feature_list+=feature_list[w] return window_based_feature_list
def setup(self, args): args = dict(enumerate((args or '').split(':'))) interval = long(args.get(0, '') or 1000000000) self.DVFS = 1 self.CMP_based_DNN_flag = 0 self.W_P = UL.get_window_past() self.freq_w = [] #a window of last frequency values for i in range(self.W_P): self.freq_w.append([]) for i in range(self.W_P): for core in range(sim.config.ncores): self.freq_w[i].append(2000.0) #defult frequency self.max_snapshots = long(args.get(1, 0)) self.num_snapshots = 0 self.interval = long(interval * sim.util.Time.NS) self.next_interval = float('inf') self.in_roi = False #sim.util.Every(self.interval, self.periodic, roi_only = True) self.sd = sim.util.StatsDelta() self.stats = { 'time': [ self.sd.getter('performance_model', core, 'elapsed_time') for core in range(sim.config.ncores) ], 'ffwd_time': [ self.sd.getter('fastforward_performance_model', core, 'fastforwarded_time') for core in range(sim.config.ncores) ], 'instrs': [ self.sd.getter('performance_model', core, 'instruction_count') for core in range(sim.config.ncores) ], 'coreinstrs': [ self.sd.getter('core', core, 'instructions') for core in range(sim.config.ncores) ], } sim.util.Every(self.interval, self.periodic, statsdelta=self.sd, roi_only=True) #interval_ns * sim.util.Time.NS ######## Get start freq to calculate corrected Cycle ############## self.start_freq = [] for core in range(sim.config.ncores): self.start_freq.append(sim.dvfs.get_frequency(core)) ## makedir for stats coming out off energystats if not os.path.exists("%sstats" % sim.config.output_dir): os.makedirs("%sstats" % sim.config.output_dir, 0777) ## mkdir for outfiles (files should be transfered between sniper and kalman) if not os.path.exists("%s/outfiles" % sniper_path): os.makedirs("%s/outfiles" % sniper_path, 0777) filename = "statsPeriodic.txt" self.fd = file(os.path.join(sim.config.output_dir, filename), 'w') ############################# self.filename_DNN_feature_label = 'DNN_feature_label.csv' self.filename_DNN_frequencies = 'DNN_frequencies.xls' self.Wfile_DNN_frequencies = file( os.path.join(sim.config.output_dir, self.filename_DNN_frequencies), 'a') self.Wfile_DNN_frequencies.write("Interval\t") for core in range(sim.config.ncores): self.Wfile_DNN_frequencies.write("%s\t" % core) self.Wfile_DNN_frequencies.write("\n") ############################# self.IdleTimePerc = [] #number of cores = 1000 (I used alot) for core in range(sim.config.ncores): self.IdleTimePerc.append(0.0)
import sniper_lib import gen_simout import DNN_feature_collector as DFC ############################################# ############################################# ####################################################################################################### # look at /sniper/scripts/user_level.py FreqList = [ '1000', '1100', '1200', '1300', '1400', '1500', '1600', '1700', '1800', '1900', '2000' ] W_P = UL.get_window_past() freq_w = [] #a window of last frequency values for i in range(W_P): freq_w.append([]) for i in range(W_P): for core in range(sim.config.ncores): freq_w[i].append(2000.0) #defult frequency ###################################################### class PeriodicStats: def setup(self, args): args = dict(enumerate((args or '').split(':'))) interval = long(args.get(0, '') or 1000000000) self.DVFS = 1