Changes between Version 64 and Version 65 of Orio


Ignore:
Timestamp:
06/13/08 21:59:29 (15 years ago)
Author:
hartono
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Orio

    v64 v65  
    237237With the module name provided in the leader annotation, Orio dynamically loads the corresponding code transformation module and uses it to transform and generate the code in the annotation body block. If the pertinent module cannot be found in the Orio module directory, an error message is produced, and the Orio optimization process is terminated. Such ''name-based dynamic loading'' provides flexibility and easy extensibility without requiring detailed knowledge or modification of the existing Orio system. 
    238238 
    239 Since Orio implementation is all in Python, to construct a new program transformation module therefore requires a Python programming skill. Transformation module writers need to create a new Python module inside `src/module` directory, where the abstract base class of the code transformation modules is located. This abstract class provides a partial implementation of the source-to-source transformation process, leaving it to subclasses to complete the implementation. The program below displays the abstract class code that inherits a class constructor and an abstract transformation function to its subclasses. 
    240  
     239Since Orio implementation is all in Python, to construct a new program transformation module therefore requires a Python programming skill. Transformation module writers need to create a new Python module inside `src/module` directory, where the abstract base class of the code transformation modules is available. This abstract class provides a partial implementation of the source-to-source transformation process, leaving it to subclasses to complete the implementation. The program below displays the abstract class code that inherits a class constructor and an abstract transformation function to its subclasses. Information about the class attributes is included in the code below as well. 
    241240 
    242241{{{ 
     
    244243# File: src/module/module.py 
    245244#  
    246 # The abstract class of the Orio's code transformation module  
    247 #  
    248   
     245 
    249246class Module:  
    250247    '''The abstract class of the Orio's code transformation module'''  
    251       
     248 
    252249    def __init__(self, cmd_line_opts, perf_params, module_code, line_no, indent_size, annot_body_code):  
    253250        '''  
    254         To instantiate a program transformation module used to transform the annotated code.  
    255   
    256         The class variables consist of the following:  
     251        The class constructor used to instantiate a program transformation module.  
     252 
     253        The following are the class attributes:  
    257254           cmd_line_opts      an object representing the command line options  
    258                               (see src/cmd_line_opts.py for more details)  
    259            perf_params        a table/mapping that maps each performance parameter to its value  
     255                              (see src/main/cmd_line_opts.py for more details)  
     256           perf_params        a table that maps each performance parameter to its value  
    260257           module_code        the code of annotation module body  
    261258           line_no            the starting line position of the module code in the source code  
     
    263260                              indentation of the leader annotation  
    264261           annot_body_code    the text located in the annotation body block  
    265            verbose            to show details of the results of the running transformation modules  
    266         '''  
    267   
     262        '''  
    268263        self.cmd_line_opts = cmd_line_opts  
    269264        self.perf_params = perf_params  
     
    273268        self.annot_body_code = annot_body_code  
    274269  
    275         # a boolean value  
    276         self.verbose = self.cmd_line_opts.verbose  
    277   
    278     #--------------------------------------------------------------------  
    279           
    280270    def transform(self):  
    281271        '''  
    282         The main code transformation procedure.  
    283         The returned value is a string value that represents the transformed/optimized code.  
    284         '''  
    285           
     272        The main code transformation procedure. The returned value is a string value that  
     273        represents the transformed/optimized code.  
     274        '''  
    286275        raise NotImplementedError('%s: unimplemented abstract function "transform"' %  
    287276                                  (self.__class__.__name__))