|
|
(14 intermediate revisions not shown.) |
Line 3: |
Line 3: |
| ---- | | ---- |
| | | |
- | == Fine-grain optimization project == | + | = Documentation Page = |
- | Yuanjie Huang (ICT, China)
| + | |
| | | |
- | This project aims to provide fine-grain optimization selection and tuning abilities in GCC, and thus enable GCC to tune default optimization heuristic of the compiler or fine optimizations for a given program on a given architecture entirely automatically using statistical and machine learning techniques from the MILEPOST project.
| + | *[[CTools:ICI:Projects:GSOC09:Fine_grain_tuning|Fine-grain optimization tuning]] |
| | | |
- | === ICI Events ===
| + | *[[CTools:ICI:Projects:GSOC09:Function_cloning_and_program_instrumentation|Function cloning and program instrumentation]] |
- | ICI events added to the framework for fine-grain tuning are documented here.
| + | |
| | | |
- | === ICI Features ===
| + | *[[CTools:ICI:Projects:GSOC09:Scripts|Scripts for these projects]] |
- | ICI features added to the framework for fine-grain tuning are documented here.
| + | |
- | {| border="1" cellspacing="0" cellpadding="3" style="text-align:left;"
| + | |
- | ! Feature name !! Type of contents !! Description
| + | |
- | |- | + | |
- | ! "main_input_filename"
| + | |
- | | array of strings, i.e., char **
| + | |
- | | Name of the file which serves as the main input file of compiler .
| + | |
- | |}
| + | |
- | '''Known Issue on Current ICI Features'''
| + | |
| | | |
- | * "function_filename" can be empty for functions generated by IPCP optimization (cp pass). | + | *[[CTools:ICI:Projects:GSOC09:Ideas_and_todos|Ideas and todos]] |
- | | + | |
- | === ICI Parameters ===
| + | |
- | ICI parameters now come with a type which should be declared when registering parameters in ICI, currently only a few basic C types are supported: void, char, unsigned char, int, unsigned int, long and unsigned long. A special type named EP_SILENT is introduced to pass parameters that is only used to pass status information to plugin; it's actually int, and is planned to be replaced by a elegant solution.
| + | |
- | The parameter type is defined in <tt>gcc/highlev-plugin-internal.h</tt> and <tt>gcc/highlev-plugin.h</tt>:
| + | |
- | <pre>
| + | |
- | typedef enum
| + | |
- | {
| + | |
- | EP_SILENT,
| + | |
- | EP_VOID,
| + | |
- | EP_CHAR,
| + | |
- | EP_UNSIGNED_CHAR,
| + | |
- | EP_INT;
| + | |
- | EP_UNSIGNED_INT,
| + | |
- | EP_LONG,
| + | |
- | EP_UNSIGNED_LONG
| + | |
- | } event_parameter_type;
| + | |
- | </pre>
| + | |
- | The representation of parameters is defined in file <tt>gcc/events.c</tt>:
| + | |
- | <pre>
| + | |
- | /* Parameter structure. */
| + | |
- | struct event_parameter
| + | |
- | {
| + | |
- | const char *name; /* Name for the parameter */
| + | |
- | const void *value; /* Pointer to data */
| + | |
- | event_parameter_type type; /* Type enumeration of value */
| + | |
- | };
| + | |
- | </pre>
| + | |
- | | + | |
- | === ICI API ===
| + | |
- | ==== ''get_event_parameter_type'': get the type of an ICI event parameter ====
| + | |
- | | + | |
- | {| cellpadding="5"
| + | |
- | | style="vertical-align:top" |
| + | |
- | {| border="1" cellspacing="0" cellpadding="3" align="left" style="text-align:left" width="400px"
| + | |
- | !Prototype
| + | |
- | |<tt>event_parameter_type get_event_parameter_type (const char *name)</tt> | + | |
- | |-
| + | |
- | !API level
| + | |
- | | FICI0
| + | |
- | |-
| + | |
- | !Declared in
| + | |
- | | ''highlev-plugin.h''
| + | |
- | |-
| + | |
- | ! Implemented in
| + | |
- | | ''events.c''
| + | |
- | |-
| + | |
- | !Inputs
| + | |
- | | ''name:'' name of the parameter
| + | |
- | |-
| + | |
- | !Return value
| + | |
- | | <tt>EP_VOID</tt> if the parameter was found;<br>otherwise, the type of parameter named ''<tt>name</tt>''
| + | |
- | |}
| + | |
- | | valign="top" | '''''Description'''''
| + | |
- | | + | |
- | '''''Prerequisites'''''
| + | |
- | | + | |
- | Parameter hash table must have been initialized.
| + | |
- | | + | |
- | '''''Outputs'''''
| + | |
- | | + | |
- | Informational message if parameters hash table does not exists.
| + | |
- | | + | |
- | '''''See also'''''
| + | |
- | | + | |
- | [[ICI_API_reference#ici_register_parameter:_register_a_new_ICI_parameter|ici_register_parameter]]
| + | |
- | | + | |
- | |}
| + | |
- | | + | |
- | === Plugins ===
| + | |
- | Plugins developed for fine-grain tuning are documented here. These plugins are developed to work with ICI-2.0 interface.
| + | |
- | ==== adapt ====
| + | |
- | '''Description'''
| + | |
- | | + | |
- | Adapt plugin provides support for GCC pass sequence record/substitution, function-specific optimization tuning, function clone and instrumentation.
| + | |
- | | + | |
- | '''Use Scenario'''
| + | |
- | | + | |
- | This plugin behaves differently depending on the ICI_ADAPT_CONTROL environmental variable, which can be either set to 1 to record information of current compilation into XML files or to 2 to reuse passes from XML files to perform passes substitution, function clone and other functionalities.
| + | |
- | | + | |
- | '''Installation'''
| + | |
- | | + | |
- | Adapt plugin is depends on MXML library, which provides XML reading and writing ability.
| + | |
- | | + | |
- | To use adapt plugin with ICI, ICI_PLUGIN environment variable should be set to the path to the plugin library (.so), and invoke gcc with either -fici or ICI_USE environment parameter.
| + | |
- | | + | |
- | '''Events and parameters'''
| + | |
- | | + | |
- | * '''"pass_execution"''': this event is triggered when a GCC pass is about to run.
| + | |
- | * '''"all_passes_manager"''':
| + | |
- | * '''"avoid_gate"''':
| + | |
- | | + | |
- | <!-- TODO: add other events needed, and give links to them. -->
| + | |
- | | + | |
- | '''State'''
| + | |
- | This plugin now can record and reuse optimization passes without problem, with the following issues to solve:
| + | |
- | | + | |
- | * The compilation won't fall to default compilation process when no corresponding XML can be found.
| + | |
- | * The plugin cannot handle interprocedual passes well.
| + | |