module.py
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 ini={}
00012 cm_kernel=None
00013
00014
00015 import json
00016
00017
00018 def init(i):
00019 return {'cm_return':0}
00020
00021
00022 def prune(i):
00023
00024 """
00025 Prune unused opt_classes
00026
00027 Input: {
00028 (prune_repo_uoa) - repo where to search
00029 (prune_module_uoa) - module to check opt_classes
00030 }
00031
00032 Output: {
00033 cm_return - return code >0 if error
00034 }
00035 """
00036
00037
00038 cm_kernel.print_for_con('')
00039 cm_kernel.print_for_con('Loading all experiments ...')
00040
00041 opt_classes_uid=[]
00042
00043 modules=ini['cfg']['prune_modules_uoa']
00044 if i.get('prune_module_uoa','')!='': modules=[i['prune_module_uoa']]
00045
00046 cm_mixed=[]
00047
00048 for m in modules:
00049 ii={'cm_run_module_uoa':m,
00050 'cm_action':'list'}
00051 if i.get('prune_repo_uoa','')!='': ii['cm_repo_uoa']=i['prune_repo_uoa']
00052 r=cm_kernel.access(ii)
00053 if r['cm_return']>0: return r
00054
00055 for q in r['cm_mixed']:
00056 cm_mixed.append(q)
00057
00058
00059 cm_kernel.print_for_con('')
00060 cm_kernel.print_for_con('Loading all compiler description entries ...')
00061
00062 ii={'cm_run_module_uoa':ini['cm_module_uid'],
00063 'cm_action':'list'}
00064 if i.get('cm_repo_uoa','')!='': ii['cm_repo_uoa']=i['cm_repo_uoa']
00065 r=cm_kernel.access(ii)
00066 if r['cm_return']>0: return r
00067
00068 cm_mixed1=r['cm_mixed']
00069
00070 for k in cm_mixed1:
00071 k1=k.get('cm_uid','')
00072 cm_kernel.print_for_con('')
00073 cm_kernel.print_for_con('Processing compiler description entry: '+k1)
00074
00075 k2d=k.get('cm_data_obj_cfg',{})
00076 k2=k2d.get('opt_classes',{})
00077
00078 to_update=False
00079 for k3 in k2:
00080 cm_kernel.print_for_con('')
00081 cm_kernel.print_for_con('Processing tuning objective: '+k3)
00082
00083 to_delete=[]
00084
00085 k4=k2[k3]
00086 for k5x in range(0, len(k4)):
00087 k5=k4[k5x]
00088 k6=k5.get('cm_uid','')
00089 if k6!='':
00090 cm_kernel.print_for_con('')
00091 cm_kernel.print_for_con('Processing class: '+k6)
00092
00093 found=False
00094 for q in cm_mixed:
00095 q1=q.get('cm_data_obj_cfg',{}).get('points',[])
00096 for qq in q1:
00097 qq1=qq['pipeline_input']['state']['9f4d948a74b0397a']['input']['tuning_objective']
00098 qq2=qq['pipeline_input']['state']['9f4d948a74b0397a']['input']['ctuning_compiler_uoa']
00099
00100 if qq1==k3 and qq2==k1:
00101 qq3=qq['pipeline_output']['state']['1048eba38df5b240']['output'].get('opt_class_uid','')
00102 if qq3!='' and qq3==k6:
00103 found=True
00104 break
00105
00106 if found: break
00107
00108 if not found:
00109 to_delete.append(k5x)
00110
00111 if len(to_delete)>0:
00112 to_update=True
00113
00114 cm_kernel.print_for_con('')
00115 cm_kernel.print_for_con('Deleting classes:')
00116 cm_kernel.print_for_con(json.dumps(to_delete, indent=2))
00117
00118 for q in sorted(to_delete, reverse=True):
00119 del k4[q]
00120
00121 if to_update:
00122 cm_kernel.print_for_con('')
00123 cm_kernel.print_for_con('Updating entry: '+k1)
00124
00125 ii={'cm_run_module_uoa':ini['cm_module_uid'],
00126 'cm_action':'update',
00127 'cm_array':k2d,
00128 'cm_data_uoa':k1}
00129 if i.get('prune_repo_uoa','')!='': ii['cm_repo_uoa']=i['prune_repo_uoa']
00130 r=cm_kernel.access(ii)
00131 if r['cm_return']>0: return r
00132
00133 return {'cm_return':0}