Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
prompf.h
Go to the documentation of this file.
00001 /*
00002 
00003   Copyright (C) 2000, 2001 Silicon Graphics, Inc.  All Rights Reserved.
00004 
00005   This program is free software; you can redistribute it and/or modify it
00006   under the terms of version 2 of the GNU General Public License as
00007   published by the Free Software Foundation.
00008 
00009   This program is distributed in the hope that it would be useful, but
00010   WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00012 
00013   Further, this software is distributed without any warranty that it is
00014   free of the rightful claim of any third person regarding infringement 
00015   or the like.  Any license provided herein, whether implied or 
00016   otherwise, applies only to this software file.  Patent licenses, if 
00017   any, provided herein do not apply to combinations of this program with 
00018   other software, or any other product whatsoever.  
00019 
00020   You should have received a copy of the GNU General Public License along
00021   with this program; if not, write the Free Software Foundation, Inc., 59
00022   Temple Place - Suite 330, Boston MA 02111-1307, USA.
00023 
00024   Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pky,
00025   Mountain View, CA 94043, or:
00026 
00027   http://www.sgi.com
00028 
00029   For further information regarding this notice, see:
00030 
00031   http://oss.sgi.com/projects/GenInfo/NoticeExplan
00032 
00033 */
00034 
00035 
00036 // -*-C++-*-
00037 
00220 #ifndef prompf_INCLUDED
00221 #define prompf_INCLUDED "prompf.h"
00222         
00223 enum PROMPF_TRANS_TYPE {
00224   MPF_UNKNOWN, 
00225   MPF_MARK_F90_LOWER, 
00226   MPF_MARK_OMP, 
00227   MPF_MARK_PREOPT, 
00228   MPF_MARK_PRELNO, 
00229   MPF_MARK_POSTLNO, 
00230   MPF_ELIMINATION, 
00231   MPF_FUSION, 
00232   MPF_FISSION, 
00233   MPF_DISTRIBUTION, 
00234   MPF_INTERCHANGE, 
00235   MPF_PRE_PEEL,
00236   MPF_POST_PEEL, 
00237   MPF_MP_TILE, 
00238   MPF_DSM_TILE, 
00239   MPF_DONEST_OUTER_TILE, 
00240   MPF_DONEST_MIDDLE_TILE,
00241   MPF_DSM_LOCAL, 
00242   MPF_DSM_IO,
00243   MPF_SINGLE_PROCESS,
00244   MPF_MP_VERSION, 
00245   MPF_PARALLEL_REGION,
00246   MPF_HOIST_MESSY_BOUNDS,
00247   MPF_DOACROSS_SYNC, 
00248   MPF_DOACROSS_OUTER_TILE, 
00249   MPF_DOACROSS_INNER_TILE,
00250   MPF_REMOVE_UNITY_TRIP,
00251   MPF_CACHE_WINDDOWN,
00252   MPF_INTERLEAVED_WINDDOWN,
00253   MPF_GENERAL_VERSION,
00254   MPF_CACHE_TILE,
00255   MPF_REGISTER_WINDDOWN,
00256   MPF_REGISTER_SSTRIP, 
00257   MPF_REGISTER_TILE, 
00258   MPF_REGISTER_STARTUP, 
00259   MPF_REGISTER_SHUTDOWN,
00260   MPF_SE_TILE, 
00261   MPF_SE_CACHE_TILE,
00262   MPF_INNER_FISSION,
00263   MPF_GATHER_SCATTER,
00264   MPF_VINTR_FISSION,
00265   MPF_PREFETCH_VERSION,
00266   MPF_OMPL_SECTIONS_LOOP,
00267   MPF_OMPL_ELIM_SECTION,
00268   MPF_OMPL_ATOMIC_CSECTION,
00269   MPF_OMPL_ATOMIC_SWAP,
00270   MPF_OMPL_ATOMIC_FETCHOP,
00271   MPF_OMPL_MASTER_IF,
00272   MPF_OMPL_FETCHOP_ATOMIC,
00273   MPF_F90_ARRAY_STMT,
00274   MPF_OUTER_SHACKLE, 
00275   MPF_INNER_SHACKLE,
00276   MPF_PREOPT_CREATE
00277 }; 
00278 
00279 enum PROMPF_CHAIN_TYPE { 
00280   MPF_CHAIN_INVALID, 
00281   MPF_CHAIN_TRANSFORM, 
00282   MPF_CHAIN_TRANSMIT
00283 }; 
00284 
00285 extern PROMPF_CHAIN_TYPE prompf_chain[]; 
00286 
00287 class PROMPF_LINES { 
00288 private: 
00289   STACK<INT> _low; 
00290   STACK<INT> _high; 
00291   MEM_POOL* _pool; 
00292 public: 
00293   PROMPF_LINES(MEM_POOL* pool): _pool(pool), _low(pool), _high(pool) {}
00294   PROMPF_LINES(WN* wn_tree, MEM_POOL* pool); 
00295   INT Sections(); 
00296   INT Low(INT i);
00297   INT High(INT i);  
00298   void Print(FILE *fp); 
00299   INT Print_Compact(FILE *fp, BOOL print_brackets=TRUE); 
00300   void Add_Line(INT line); 
00301   void Add_Lines(WN* wn_tree);
00302 }; 
00303 
00304 class PROMPF_TRANS {
00305 private: 
00306   PROMPF_TRANS_TYPE _type; 
00307   STACK<INT> _old_loops; 
00308   STACK<INT> _new_loops; 
00309   STACK<INT> _prev_loops; 
00310   STACK<PROMPF_LINES*> _old_lines; 
00311   STACK<PROMPF_LINES*> _new_lines; 
00312   char* _index_name; 
00313   MEM_POOL* _pool; 
00314 public: 
00315   PROMPF_TRANS(MEM_POOL* pool): _pool(pool), _type(MPF_UNKNOWN), 
00316     _old_loops(pool), _new_loops(pool), _prev_loops(pool), 
00317     _old_lines(pool), _new_lines(pool), _index_name(NULL) {} 
00318   PROMPF_TRANS(STACK<INT>* old_loops, STACK<INT>* new_loops,
00319     STACK<INT>* prev_loops, STACK<PROMPF_LINES>* new_lines, 
00320     char* index_name, MEM_POOL* pool); 
00321   PROMPF_TRANS_TYPE Type() {return _type;}
00322   INT Old_Loop_Count() {return _old_loops.Elements();}
00323   INT New_Loop_Count() {return _new_loops.Elements();}
00324   INT Prev_Loop_Count() {return _prev_loops.Elements();}
00325   INT Old_Loop(INT i); 
00326   INT New_Loop(INT i); 
00327   INT Prev_Loop(INT i); 
00328   void Set_Type(PROMPF_TRANS_TYPE type) {_type = type;}
00329   void Add_Old_Loop(INT id) {_old_loops.Push(id);}
00330   void Add_New_Loop(INT id) {_new_loops.Push(id);} 
00331   void Add_Prev_Loop(INT id) {_prev_loops.Push(id);} 
00332   void Add_Old_Lines(PROMPF_LINES* pl) {_old_lines.Push(pl);}
00333   void Add_New_Lines(PROMPF_LINES* pl) {_new_lines.Push(pl);}
00334   void Add_Index_Name(char* index_name);
00335   void Print(FILE* fp); 
00336   void Print_Compact(FILE* fp); 
00337 }; 
00338 
00339 enum PROMPF_ID_TYPE { 
00340   MPID_UNKNOWN, 
00341   MPID_FUNC_ENTRY, 
00342   MPID_DO_LOOP, 
00343   MPID_PAR_REGION, 
00344   MPID_PAR_SECTION, 
00345   MPID_SECTION, 
00346   MPID_BARRIER, 
00347   MPID_SINGLE_PROCESS,
00348   MPID_CRITICAL_SECTION,
00349   MPID_MASTER,
00350   MPID_ORDERED, 
00351   MPID_PAR_SECTIONS, 
00352   MPID_ATOMIC
00353 }; 
00354 
00355 class PROMPF_ID { 
00356 private: 
00357   PROMPF_ID_TYPE _type; 
00358   BOOL _valid; 
00359   INT _last_trans; 
00360   MEM_POOL* _pool; 
00361 public: 
00362   PROMPF_ID(PROMPF_ID_TYPE type, BOOL valid, INT last_trans, MEM_POOL* pool): 
00363     _pool(pool), _type(type), _valid(valid), _last_trans(last_trans) {}
00364   BOOL Is_Valid() {return _valid;}
00365   BOOL Last_Trans() {return _last_trans;}
00366   void Invalidate() {_valid = FALSE;}
00367   void Validate() {_valid = TRUE;}
00368   void Set_Last_Trans(INT v) {_last_trans = v;} 
00369   void Print(FILE* fp, INT entry=0); 
00370 };
00371 
00372 enum PROMPF_TRANS_LOG {
00373   PTL_F90_LOWER, 
00374   PTL_OMP, 
00375   PTL_PREOPT, 
00376   PTL_PRELNO, 
00377   PTL_POSTLNO
00378 }; 
00379 
00380 class PROMPF_INFO { 
00381 private: 
00382   BOOL _enabled; 
00383   INT _first_id; 
00384   STACK<PROMPF_TRANS*> _trans_stack; 
00385   STACK<PROMPF_ID*> _id_stack;   
00386   INT _trans_checkpoint; 
00387   PROMPF_TRANS* Trans(INT i) {return _trans_stack.Bottom_nth(i);}
00388   INT Last_Trans() {return _trans_stack.Elements() - 1;}
00389   void Reset_Last_Trans(INT old_id);
00390   PROMPF_ID* Id(INT i) {return _id_stack.Bottom_nth(i - _first_id);}
00391   INT First_Id() {return _first_id;}
00392   INT Last_Id() {return _first_id + _id_stack.Elements() - 1;}
00393   PROMPF_ID* Remove_Id() {return _id_stack.Pop();}
00394   PROMPF_INFO(MEM_POOL* pool): _pool(pool), _enabled(FALSE), 
00395     _trans_stack(pool), _id_stack(pool), _trans_checkpoint(-1)
00396     {_trans_stack.Clear(); _id_stack.Clear();}
00397   void Add_Trans(PROMPF_TRANS* pt);
00398   PROMPF_TRANS* Remove_Trans();
00399   void Add_Id(PROMPF_ID* pi) {_id_stack.Push(pi);} 
00400   void Update_Id(INT i, INT trans_index) 
00401     { _id_stack.Bottom_nth(i - _first_id)->Set_Last_Trans(trans_index);} 
00402   void Push_Original_Loops(INT id_trans, INT last_trans, 
00403     STACK<INT>* oloop_stack);
00404   BOOL Check_Old_Ids(INT old_ids[], INT new_ids[], INT nloops); 
00405   BOOL Check_New_Ids(INT new_ids[], INT nloops); 
00406   void Prompf_Info_Traverse(WN* wn_tree, WN* wn_region); 
00407   void Check_Traverse(FILE* fp, WN* wn_tree, BOOL ids[], WN* wn_region); 
00408   MEM_POOL* _pool; 
00409 public: 
00410   PROMPF_INFO(WN* wn_func, MEM_POOL* pool);
00411   BOOL Is_Enabled() {return _enabled;} 
00412   void Disable() {_enabled = FALSE;}
00413   void Enable() {_enabled = TRUE;}
00414   void Mark_F90_Lower(); 
00415   void Mark_Omp(); 
00416   void Mark_Preopt(); 
00417   void Mark_Prelno(); 
00418   void Mark_Postlno(); 
00419   void Elimination(INT old_loop); 
00420   void Undo_Elimination();
00421   void Fusion(INT old_loops[], INT new_loop);
00422   void Undo_Fusion();
00423   void Fission(INT old_loops[], PROMPF_LINES* old_lines[], INT new_loops[], 
00424     PROMPF_LINES* new_lines[],  INT nloops); 
00425   void Distribution(INT old_loops[], PROMPF_LINES* old_lines[], 
00426     INT new_loops[], PROMPF_LINES* new_lines[],  INT nloops); 
00427   void Interchange(INT old_loops[], INT new_loops[], INT nloops); 
00428   void Pre_Peel(INT old_loops[], INT new_loops[], INT nloops); 
00429   void Undo_Pre_Peel();
00430   void Post_Peel(INT old_loops[], INT new_loops[], INT nloops); 
00431   void Undo_Post_Peel();
00432   void Mp_Tile(INT old_loop, INT new_loops[], INT nloops); 
00433   void Dsm_Tile(INT old_loop, INT new_loops[], INT nloops); 
00434   void Donest_Outer_Tile(INT old_loops[], INT new_loop, INT nloops);
00435   void Donest_Middle_Tile(INT old_loop, INT new_loop); 
00436   void Dsm_Local(INT new_loop, PROMPF_LINES* pl, char* index_name); 
00437   void Dsm_Io(INT new_loop, INT linenum, char* index_name); 
00438   void Single_Process(INT new_id, PROMPF_LINES* pl); 
00439   void Mp_Version(INT old_loops[], INT new_loops[], PROMPF_ID_TYPE id_type[], 
00440     INT nloops); 
00441   void Parallel_Region(INT old_loop, INT new_loop); 
00442   void Hoist_Messy_Bounds(INT old_loop[], INT new_loop[], INT nloops); 
00443   void Doacross_Sync(INT old_loop, INT new_loop); 
00444   void Doacross_Outer_Tile(INT old_loop, INT new_loop); 
00445   void Doacross_Inner_Tile(INT old_loop, INT new_loop); 
00446   void Remove_Unity_Trip(INT old_loop); 
00447   void Cache_Winddown(INT old_loops[], INT new_loops[], INT nloops); 
00448   void Interleaved_Winddown(INT old_loops[], INT new_loops[], INT nloops); 
00449   void General_Version(INT old_loops[], INT new_loops[], INT nloops); 
00450   void Cache_Tile(INT old_loop, INT new_loop); 
00451   void Register_Winddown(INT old_loops[], INT new_loops[], INT nloops); 
00452   void Register_SStrip(INT old_loops[], INT new_loops[], INT nloops); 
00453   void Register_Tile(INT loop); 
00454   void Register_Startup(INT old_loops[], INT new_loops[], INT nloops); 
00455   void Register_Shutdown(INT old_loops[], INT new_loops[], INT nloops); 
00456   void Se_Tile(INT old_loop, INT new_loop); 
00457   void Se_Cache_Tile(INT old_loop, INT new_loop); 
00458   void Inner_Fission(INT old_loop, PROMPF_LINES* old_lines, INT new_loops[],
00459     PROMPF_LINES* new_lines[], INT nloops);
00460   void Gather_Scatter(INT old_loop, PROMPF_LINES* old_lines, INT new_loops[],
00461     PROMPF_LINES* new_lines[], INT nloops);
00462   void Vintr_Fission(INT old_loop, PROMPF_LINES* old_lines, INT new_loops[],
00463     PROMPF_LINES* new_lines[], INT nloops);
00464   void Prefetch_Version(INT old_loops[], INT new_loops[], INT nloops); 
00465   void OMPL_Sections_To_Loop(INT old_id); 
00466   void OMPL_Eliminate_Section(INT old_id); 
00467   void OMPL_Atomic_To_Critical_Section(INT old_id); 
00468   void OMPL_Atomic_To_Swap(INT old_id); 
00469   void OMPL_Atomic_To_FetchAndOp(INT old_id); 
00470   void OMPL_Master_To_If(INT old_id); 
00471   void OMPL_Fetchop_Atomic(INT new_id, PROMPF_LINES* pl); 
00472   void F90_Array_Stmt(INT new_loop, PROMPF_LINES* pl, char* index_name);
00473   void Outer_Shackle(INT new_loop, PROMPF_LINES* pl, char* index_name);
00474   void Inner_Shackle(INT old_loop, INT new_loop);
00475   void Preopt_Create(INT new_loop, PROMPF_LINES* pl, char* index_name); 
00476   void Clear();
00477   void Save();
00478   void Restore();
00479   void Print(FILE* fp); 
00480   INT Check(FILE* fp, WN* wn_func);
00481   void Print_Compact(FILE* fp, PROMPF_TRANS_LOG ptl); 
00482 };
00483 
00484 extern WN_MAP Prompf_Id_Map; 
00485 extern PROMPF_INFO* Prompf_Info; 
00486 extern MEM_POOL PROMPF_pool;
00487 
00488 extern PROMPF_ID_TYPE Prompf_Id_Type(WN* wn_ref, WN* wn_region, 
00489   BOOL* is_first=NULL); 
00490 
00491 extern void Prompf_Assign_Ids(WN* wn_old, WN* wn_new, STACK<WN*>* old_stack, 
00492   STACK<WN*>* new_stack, BOOL copy_ids, INT max_ids=INT32_MAX);
00493 
00494 #endif /* prompf_INCLUDED */ 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines