Welcome    Usage    Browse    Find CID    Search     Log in

cM API Documentation

module.py

Go to the documentation of this file.
00001 #
00002 # Collective Mind
00003 #
00004 # See cM LICENSE.txt for licensing details.
00005 # See cM Copyright.txt for copyright details.
00006 #
00007 # Developer(s): (C) Grigori Fursin, started on 2011.09
00008 #
00009 
00010 # Should always be here
00011 ini={}
00012 cm_kernel=None
00013 
00014 # Local settings
00015 import json
00016 
00017 # ============================================================================
00018 def init(i):
00019     return {'cm_return':0}
00020 
00021 # ============================================================================
00022 def explore(i):
00023 
00024     """
00025     Explore a few points from mobile, cloud, etc 
00026 
00027     Input:  {
00028               predefined_uoa                     - data UOA with pre-defined input to compiler optimization scenario
00029 
00030               mobile_mode - 'build' or 'process' - mode during crowdsourcing auto-tuning using mobiles
00031 
00032               (system_info)                      - detected system info by the mobile/cloud/grid system
00033 
00034               (new_src_uoa)                      - new src UOA in tmp repository
00035               (measured_frequency)               - measured frequency (if supported)
00036               (execution_info)                   - list of list of execution times per binary - 1 coarse-grain exploration step
00037               (execution_info_min)               - list of minimal execution times per 1 coarse-grain exploration step
00038               (execution_info_ct_repeat_main)    - CT_REPEAT_MAIN got during calibration
00039               (built_files)                      - list of unique built files (with UIDs)
00040             }
00041 
00042     Output: {
00043               cm_return     - if =0, success
00044 
00045               (new_src_uoa) - if src were copied, new UID in tmp repo
00046             }
00047 
00048     """
00049 
00050     pi=i.get('predefined_uoa','')
00051     if pi=='':
00052        return {'cm_return':1, 'cm_error':'"predefined_uoa" is not defined'}
00053 
00054     mm=i.get('mobile_mode','')
00055     if mm=='':
00056        return {'cm_return':1, 'cm_error':'"mobile_mode" is not defined'}
00057 
00058     # Loading predefined input
00059     r=cm_kernel.access({'cm_run_module_uoa':ini['cm_module_uid'],
00060                          'cm_action':'load',
00061                          'cm_data_uoa':pi})
00062     if r['cm_return']>0: return r
00063 
00064     dpi=r['cm_data_obj']['cfg']
00065 
00066     api=dpi.get('predefined_input',{})
00067     if len(api)==0:
00068        return {'cm_return':1, 'cm_error':'"predefined_input" is not found in predefined entry'}
00069 
00070     system_info=i.get('system_info',{})
00071     if len(system_info)>0:
00072        api['system_info']=system_info
00073 
00074     api['mobile_mode']=mm
00075     if mm=='build':
00076        api['copy_built_executables']='yes'
00077        api['copy_src_to_tmp']='yes'
00078     elif mm=='report':
00079        new_src_uoa=i.get('new_src_uoa','')
00080        if new_src_uoa=='':
00081           return {'cm_return':1, 'cm_error':'"new_src_uoa" is not defined'}
00082        api['new_src_uoa']=new_src_uoa
00083 
00084        api['measured_frequency']=i.get('measured_frequency','')
00085 
00086        ei=i.get('execution_info',[])
00087        if len(ei)==0:
00088           return {'cm_return':1, 'cm_error':'"execution_info" is empty'}
00089        api['execution_info']=ei
00090 
00091        eim=i.get('execution_info_min',[])
00092        if len(ei)==0:
00093           return {'cm_return':1, 'cm_error':'"execution_info_min" is empty'}
00094        api['execution_info_min']=eim
00095 
00096        ct_repeat_main=i.get('execution_info_ct_repeat_main','')
00097        if ct_repeat_main=='':
00098           return {'cm_return':1, 'cm_error':'"execution_info_ct_repeat_main" is not defined'}
00099        api['execution_info_ct_repeat_main']=ct_repeat_main
00100 
00101        built_files=i.get('built_files',[])
00102        if len(built_files)==0:
00103           return {'cm_return':1, 'cm_error':'"built_files" is empty'}
00104        api['built_files']=built_files
00105 
00106        # Set recording to repository
00107        api['exploration_scenario']['save_results_in_repository']='yes'
00108        api['original_input']['#form_4df5b2509a4feabf_1##profitable_results_module']='e480890e45f8ad4f'
00109 
00110     # Run scenario
00111     api['cm_run_module_uoa']=ini['cfg']['cm_modules']['ctuning.pipeline.build_and_run_program']
00112     return cm_kernel.access(api)

Generated on Wed May 28 02:49:02 2014 for Collective Mind Framework by DoxyGen 1.6.1
Concept, design and coordination: Grigori Fursin (C) 1993-2013