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 #ifndef _LEGO_PRAGMA_INCLUDED_ 00037 #define _LEGO_PRAGMA_INCLUDED_ 00038 00039 /*********************************************************************** 00040 * 00041 * Exported Types 00042 * ============== 00043 * 00044 * class DISTR_DIM 00045 * Store information about a single dimension of a distributed array. 00046 * 00047 * 00048 * Exported Methods 00049 * ---------------- 00050 * 00051 * DISTR_DIM () 00052 * constructor 00053 * 00054 * ~DISTR_DIM () 00055 * destructor 00056 * 00057 * BOOL operator ==(const DISTR_DIM& test_dim) const; 00058 * Compare two distributions, return true if they are the same 00059 * (including chunksize in cyclic(k)). 00060 * 00061 * BOOL CyclicOne () 00062 * Return TRUE if cyclic(1), FALSE otherwise. 00063 * 00064 * DISTRIBUTE_TYPE Distr_Type() 00065 * Return the type of distribution. 00066 * 00067 * INT64 Chunk_Const_Val() 00068 * Return the chunksize (must be constant) 00069 * 00070 * WN *Chunk_WN() 00071 * Return the original WHIRL expression for the chunksize. 00072 * 00073 * WN *Chunksize() 00074 * Return a new copy of the WHIRL expression for the chunksize. 00075 * 00076 * void Evaluate_Chunk_Into_Symbol (SYMBOL* s, WN* stid_wn) 00077 * Given an STID that evaluates the chunksize expr into the 00078 * symbol pointer, store the symbols and stid_wn for subsequent DU-info. 00079 * 00080 * void Init_Block_Star (DISTRIBUTE_TYPE dt); 00081 * Initialize routine for block/star distributions. 00082 * 00083 * void Init_Cyclic_Const (DISTRIBUTE_TYPE dt, INT64 const_val, WN* pwn) 00084 * Initialize routines for cyclic_const 00085 * 00086 * void Init_Cyclic_Expr (DISTRIBUTE_TYPE dt, WN* val_wn) 00087 * Initialize routine for cyclic_expr 00088 * 00089 * void Print (FILE* fp) 00090 * Standard print routine. 00091 * 00092 * 00093 * Exported Type 00094 * ============= 00095 * 00096 * class DISTR_ARRAY 00097 * Store all the information for a single data distribution pragma. 00098 * 00099 * Exported Methods 00100 * ---------------- 00101 * 00102 * DISTR_ARRAY () 00103 * DISTR_ARRAY (DISTR_DIM* dims, WN *first_pragma, WN *last_pragma, 00104 * WN** bounds_wns) 00105 * Constructors. 00106 * 00107 * ~DISTR_ARRAY () 00108 * Destructor. 00109 * 00110 * DISTR_DIM *Dims() 00111 * Return a pointer to this arrays distributed dimensions info. 00112 * 00113 * DISTR_DIM *Get_Dim (INT i) 00114 * Return a pointer this arrays distributed dimension, "i" 00115 * 00116 * INT Num_Distr_Dim () 00117 * Return the number of distributed dimensions in this array. 00118 * 00119 * WN* First_Pragma_WN () 00120 * Return a pointer to the first pragma node. 00121 * 00122 * WN* Last_Pragma_WN () 00123 * Return a pointer to the last pragma node. 00124 * 00125 * mBOOL Is_Compiler_Generated () 00126 * Return TRUE if these pragmas were compiler-generated, 00127 * FALSE otherwise. 00128 * 00129 * WN* void Set_Last_Pragma_WN (WN* lwn) 00130 * Store the pointer to the last pragma node. 00131 * 00132 * WN* Array_Size_WN (INT dim) 00133 * Return (a cloned tree of) the expression 00134 * for the size of dimension dim of the array. 00135 * 00136 * BOOL Has_Onto () 00137 * Return TRUE if this distribution had an ONTO clause, FALSE otherwise. 00138 * 00139 * INT64 Onto(INT32 i) 00140 * Return the size of the onto value in dimension "i" 00141 * 00142 * DISTR_INFO* Dinfo() 00143 * void Set_Dinfo(DISTR_INFO *dinfo) 00144 * Routines to get and set the dinfo. 00145 * 00146 * mBOOL DACT_Equiv(DISTR_ARRAY *test_dact, INT32 my_dim, INT32 test_dim) 00147 * Compare "this" and the given dact in the specified dimensions. 00148 * Return TRUE if the distributions are the same, and the array 00149 * bounds are equivalent. 00150 * 00151 * mBOOL DACT_Equiv(DISTR_ARRAY *test_dact) 00152 * Return TRUE if "this" and "test_dact" are equiv in all dimensions. 00153 * 00154 * void Convert_Expr_To_Symbol () 00155 * For each distribute_cyclic_expr, evaluate the expr into a 00156 * local symbol, and replace the WHIRL tree in DISTR_DIM with the sym. 00157 * 00158 * WN *Chunksize (INT i) 00159 * Return a usable whirl expression for the chunksize in dimension "i". 00160 * 00161 * void Print (FILE* fp) const 00162 * Standard Print method. 00163 * 00164 * 00165 * 00166 * Exported Type 00167 * ============= 00168 * 00169 * class DISTR_INFO 00170 * Store all the data distribution pragmas for an array. 00171 * 00172 * Exported Methods 00173 * ---------------- 00174 * 00175 * DISTR_INFO (mBOOL isreshaped, INT numdim, SYMBOL* array) 00176 * Constructor 00177 * 00178 * ~DISTR_INFO () 00179 * Destructor 00180 * 00181 * mBOOL IsReshaped() 00182 * Return TRUE if array is reshaped. 00183 * 00184 * mBOOL IsDynamic() 00185 * Return TRUE if dynamic. 00186 * 00187 * void Set_Dynamic() 00188 * Set dynamic. 00189 * 00190 * INT Num_Dim() 00191 * Return number of dimensions in the array. 00192 * 00193 * SYMBOL* Array() 00194 * Return SYMBOL* for the distributed array. 00195 * 00196 * ST* Array_ST() 00197 * Return ST* of the array. 00198 * 00199 * ST* Dart_ST() 00200 * Return ST* of the dart for the array. 00201 * 00202 * void Find_Alloca () 00203 * For a regular distributed local adjustable-sized array, 00204 * locate the alloca in the function preamble and setup 00205 * DU-chains and alias info. 00206 * 00207 * WN* Load_Distr_Array () 00208 * Load the address of a distributed array, 00209 * and update alias/DU info as required. 00210 * Return an ldid or an lda of the array. 00211 * 00212 * WN* Load_New_Distr_Array () 00213 * Load the (new) address of a reshaped distributed array. 00214 * Return an ldid or an lda of the array. 00215 * Called only for reshaped arrays in a COMMON block, after 00216 * array lowering. 00217 * 00218 * SYMBOL* Array_Common_Symbol() 00219 * If a common reshaped array, return the symbol for the new array 00220 * ST. 00221 * 00222 * void Set_Array_Alias_WN (WN* wn) 00223 * WN* Get_Array_Alias_WN () 00224 * Store/Fetch WHIRL node that references the array. 00225 * Use to copy-alias-info. 00226 * 00227 * void Set_Array_Ptr_Alias_WN (WN* wn) { _array_ptr_alias_wn = wn; } 00228 * WN* Get_Array_Ptr_Alias_WN () { return _array_ptr_alias_wn; } 00229 * Store/Fetch WHIRL node that dereferences the array. 00230 * Use to copy-alias-info. 00231 * 00232 * void Set_Array_Def_WN (WN* wn) 00233 * void Add_Array_Use_WN (WN* use_wn) 00234 * Store the def WN* of the array. Add uses and update DU-chains. 00235 * 00236 * WN* Get_Array_Def_WN () 00237 * Used just for debugging 00238 * 00239 * WN* DART_Ldid (); 00240 * Return an LDID for the dart, with updated alias info and DU-chains. 00241 * void DART_Stid (WN* stid_wn); 00242 * Given an STID for the dart, update alias and DU info. 00243 * void DART_Ptr_Ref(WN* wn) 00244 * Given an ISTORE/ILOAD for the dart, update alias info. 00245 * 00246 * SYMBOL* Get_Dimsize (INT i) 00247 * SYMBOL* Get_Numprocs (INT i) 00248 * Return SYMBOLS* for dimsize/numprocs in specified dimension. 00249 * 00250 * WN* Numprocs(INT dim); 00251 * WN* Dimsize(INT dim); 00252 * WN* Chunksize(INT dim); 00253 * Return an ldid of the numprocs/dimsize/chunksize 00254 * 00255 * void Numprocs_Ldid (INT dim, WN* ldid_wn); 00256 * void Numprocs_Stid (INT dim, WN* stid_wn); 00257 * void Dimsize_Ldid (INT dim, WN* ldid_wn); 00258 * void Dimsize_Stid (INT dim, WN* stid_wn); 00259 * Routines to handle alias info and DU-chains for dimsize/numprocs. 00260 * 00261 * WN* Get_Array_Dim_Size (INT dim); 00262 * Return a WHIRL expr for the upper bound of the given dim. 00263 * 00264 * void Add_Dact (DISTR_ARRAY* dact) 00265 * Insert a dact into this dinfo. 00266 * 00267 * INT Num_Dact () 00268 * Return the number of dacts in this dinfo. 00269 * 00270 * DISTR_ARRAY* Get_Dact (INT i) 00271 * Return dact# i. 00272 * 00273 * void Add_Redistr (DISTR_ARRAY* redistr) 00274 * Add a redistribute dact. 00275 * 00276 * INT Num_Redistr () 00277 * Return the number of redistribute dacts in this dinfo. 00278 * 00279 * DISTR_ARRAY* Get_Redistr (INT i) 00280 * Return redistributed dact# i 00281 * 00282 * void Add_Gen_Redistr (DISTR_ARRAY* redistr) 00283 * Add a redistribute dact to those collected after LNO, during lego-gen. 00284 * 00285 * INT Num_Redistr () 00286 * Return the number of redistribute dacts (after LNO, during lego-gen) 00287 * in this dinfo. 00288 * 00289 * DISTR_ARRAY* Get_Redistr (INT i) 00290 * Return redistributed dact# i from the list after LNO, during lego-gen. 00291 * 00292 * void Set_Orig_TY(TY_IDX ty) 00293 * TY_IDX Orig_TY() 00294 * Store/fetch the original TY. Useful since the original 00295 * TY gets reshaped. 00296 * 00297 * void Print (FILE* fp) 00298 * Standard Print method. 00299 * 00300 * 00301 * Exported Type 00302 * ============= 00303 * 00304 * class DISTR_GLOBAL_INFO 00305 * Store information about global arrays 00306 * 00307 * Exported Methods 00308 * ---------------- 00309 * 00310 * DISTR_GLOBAL_INFO(TY_IDX ty) 00311 * Constructor 00312 * 00313 * TY_IDX Get_TY () 00314 * Return the original TY of the array. 00315 * 00316 * 00317 * Exported Types 00318 * ============== 00319 * 00320 * typedef HASH_TABLE<ST*, DISTR_INFO*> DA_HASH_TABLE; 00321 * Hash-table of ST entries and the corresponding DISTR_INFO 00322 * for the array. 00323 * 00324 * typedef STACK<DISTR_INFO*> DA_STACK; 00325 * Stack of DISTR_INFOs in the PU. Duplicate of hash-table 00326 * (i.e. same entries) but easier to walk since it's a stack. 00327 * 00328 * typedef HASH_TABLE<ST*, DISTR_GLOBAL_INFO*> DA_GLOBAL_HASH_TABLE; 00329 * Hash-table of ST entries and the corresponding DISTR_INFO 00330 * for the array, for global arrays 00331 * 00332 * Exported Functions 00333 * ================== 00334 * 00335 * extern void Read_Distr_Pragmas (WN* func_nd); 00336 * 00337 * extern WN *Read_Pragma_Distribute(WN *pwn); 00338 * 00339 * extern WN* Read_Pragma_Redistribute (WN* pwn, BOOL gen_phase = FALSE) 00340 * 00341 * extern WN* Load_Distr_Array (ST* array_st) 00342 * Load the start address of the given array. 00343 * 00344 * extern WN* Numprocs (ST* array_st, INT dim, BOOL inside_loop, WN** block_wn) 00345 * Return a WHIRL tree for numprocs in dimension "dim" of given 00346 * array, based on a dynamic runtime lookup. block_wn contains 00347 * generated statement code. inside_loop tells whether the code will 00348 * be inserted within a loop. 00349 * 00350 * Exported Variables 00351 * ================== 00352 * 00353 * extern DA_HASH_TABLE *da_hash; 00354 * For each ST, store all data distribution pragmas. 00355 * 00356 * extern DA_HASH_TABLE *da_global; 00357 * Store information for global distributed arrays across PU processing 00358 * 00359 ***********************************************************************/ 00360 00361 #include "defs.h" 00362 #include "wn.h" 00363 #include "stab.h" 00364 #include "cxx_hash.h" 00365 #include "access_vector.h" 00366 #include "wn_pragmas.h" 00367 #include "lego.h" 00368 #include "opt_du.h" 00369 #include "opt_alias_interface.h" 00370 #include "lego_util.h" 00371 #include "lwn_util.h" 00372 00373 /*********************************************************************** 00374 * 00375 * External declarations 00376 * 00377 ***********************************************************************/ 00378 00379 extern DU_MANAGER *Du_Mgr; // PU DU manager 00380 extern class ALIAS_MANAGER *Alias_Mgr; // Alias manager 00381 extern WN *Current_Func_Node; // whirl node for current function 00382 00383 class DISTR_DIM { 00384 DISTRIBUTE_TYPE _distr_type; /* DISTRIBUTE_STAR, 00385 * DISTRIBUTE_BLOCK, 00386 * DISTRIBUTE_CYCLIC_EXPR, or 00387 * DISTRIBUTE_CYCLIC_CONST. 00388 * (definition from wn_pragmas.h) 00389 */ 00390 union { /* If cyclic then expr for chunksize. */ 00391 INT64 const_val; /* if int-const then store value */ 00392 SYMBOL* sym; /* Later replace by symbol containing value. */ 00393 } _chunksize; 00394 WN* _chunk_val_wn; /* if cyclic_expr (non-const) then expr-WN */ 00395 WN* _chunk_stid_wn; /* if cyclic_expr, then this stores the 00396 * stid that evaluates the expr into 00397 * the symbol. Useful for alias-info/du-chains. 00398 */ 00399 00400 public: 00401 DISTR_DIM () { 00402 _chunksize.const_val = 0; 00403 _chunk_val_wn = NULL; 00404 _chunk_stid_wn = NULL; 00405 } 00406 ~DISTR_DIM () { 00407 if (_distr_type == DISTRIBUTE_CYCLIC_EXPR) 00408 CXX_DELETE(_chunksize.sym, LEGO_pool); 00409 } 00410 BOOL operator ==(const DISTR_DIM& test_dim) const; 00411 00412 BOOL CyclicOne () { 00413 if ((_distr_type == DISTRIBUTE_CYCLIC_CONST) && 00414 (_chunksize.const_val == 1)) return TRUE; 00415 return FALSE; 00416 } 00417 DISTRIBUTE_TYPE Distr_Type() const { return _distr_type; } 00418 INT64 Chunk_Const_Val() const { return _chunksize.const_val; } 00419 WN *Chunk_WN() const { return _chunk_val_wn; } 00420 WN *Chunksize(); 00421 /* 00422 * s is the symbol into which the chunksize is evaluated. 00423 * stid_wn is the stid, which we store for alias and du-info. 00424 */ 00425 void Evaluate_Chunk_Into_Symbol (SYMBOL* s, WN* stid_wn) { 00426 Is_True (_distr_type == DISTRIBUTE_CYCLIC_EXPR, 00427 ("Replacing Val with symbol for non CYCLIC_EXPR")); 00428 _chunksize.sym = s; 00429 _chunk_stid_wn = stid_wn; 00430 } 00431 // for block/star 00432 void Init_Block_Star (DISTRIBUTE_TYPE dt); 00433 // for cyclic_const 00434 void Init_Cyclic_Const (DISTRIBUTE_TYPE dt, INT64 const_val, WN* pwn); 00435 // for cyclic_expr 00436 void Init_Cyclic_Expr (DISTRIBUTE_TYPE dt, WN* val_wn); 00437 // for cyclic_expr, but with runtime lookup of chunksize 00438 void Init_Cyclic_Expr_Runtime (DISTRIBUTE_TYPE dt, INT32 dimnum); 00439 void Print (FILE* fp) const; 00440 }; 00441 00442 class DISTR_INFO; 00443 00444 class DISTR_ARRAY { 00445 DISTR_DIM*_dims; /* distr of each dimension */ 00446 WN* _first_pragma_wn; /* pointer to first pragma node for this 00447 * particular distribute pragma. 00448 */ 00449 WN* _last_pragma_wn; /* pointer to last pragma node for this 00450 * particular distribute pragma. 00451 */ 00452 WN** _bounds_wns; /* array of pointer to bound xpragma nodes, 00453 * one for each dimension. 00454 */ 00455 INT64* _onto; /* array of onto values, if any */ 00456 DISTR_INFO* _dinfo; 00457 00458 public: 00459 DISTR_ARRAY () {} 00460 DISTR_ARRAY (DISTR_DIM* dims, 00461 WN *first_pragma, 00462 WN* last_pragma, 00463 WN** bounds_wns, 00464 INT64* onto) : 00465 _dims(dims), 00466 _first_pragma_wn(first_pragma), 00467 _last_pragma_wn(last_pragma), 00468 _dinfo(NULL), 00469 _bounds_wns(bounds_wns), 00470 _onto(onto) 00471 { } 00472 00473 ~DISTR_ARRAY () { 00474 CXX_DELETE_ARRAY (_dims, LEGO_pool); 00475 CXX_DELETE_ARRAY (_bounds_wns, LEGO_pool); 00476 if (_onto) CXX_DELETE_ARRAY (_onto, LEGO_pool); 00477 } 00478 00479 DISTR_DIM *Dims() const { return _dims; } 00480 DISTR_DIM *Get_Dim (INT i) const { return &(_dims[i]); } 00481 INT Num_Distr_Dim (); 00482 00483 WN* First_Pragma_WN () const { return _first_pragma_wn; } 00484 WN* Last_Pragma_WN () const { return _last_pragma_wn; } 00485 mBOOL Is_Compiler_Generated () const { 00486 return WN_pragma_compiler_generated(_first_pragma_wn); 00487 } 00488 00489 /* Caution: This routine returns a cloned tree: if the caller only needs 00490 * to look at it, then the caller should explicitly free it when done. 00491 */ 00492 WN* Array_Size_WN (INT i) const { 00493 WN* copy_wn = LWN_Copy_Tree(WN_kid0(_bounds_wns[i])); 00494 LWN_Copy_Def_Use (WN_kid0(_bounds_wns[i]), copy_wn, Du_Mgr); 00495 return copy_wn; 00496 } 00497 00498 BOOL Has_Onto () const { return (_onto != NULL); } 00499 INT64 Onto(INT32 i) const { 00500 Is_True (_onto,("Onto: asking for onto-value, but no onto specified\n")); 00501 return _onto[i]; 00502 } 00503 DISTR_INFO* Dinfo() const { return _dinfo; } 00504 void Set_Dinfo(DISTR_INFO *dinfo) { _dinfo = dinfo; } 00505 mBOOL DACT_Equiv(DISTR_ARRAY *test_dact, INT32 my_dim, INT32 test_dim); 00506 mBOOL DACT_Equiv(DISTR_ARRAY *test_dact); 00507 void Convert_Expr_To_Symbol (); 00508 WN *Chunksize (INT i) { return _dims[i].Chunksize(); } 00509 void Print (FILE* fp) const; 00510 }; 00511 00512 typedef DYN_ARRAY<DISTR_ARRAY*> DISTR_ARRAY_DA; 00513 00514 class DISTR_INFO { 00515 mBOOL _isreshaped; /* whether array is reshaped or not */ 00516 mBOOL _isdynamic; /* whether we saw a c$dynamic or not */ 00517 INT _num_dim; /* total number of dimensions in array */ 00518 SYMBOL* _array; /* Symbol for ST entry for original array */ 00519 ST* _dart_st; /* ST entry for runtime distr-tag for array */ 00520 00521 WN* _dart_ptr_alias_wn; /* store alias-wn for derefs of the dart */ 00522 DYN_ARRAY<WN*> _dart_wn; /* store all wns that define the dart */ 00523 00524 WN* _ec_dart_def_wn;/* WN that defines dart used in error checking */ 00525 WN* _ec_dart_ptr_wn;/* WN of pointer to dart used in error checking */ 00526 00527 00528 WN* _array_alias_wn;/* store alias-wn for references to array */ 00529 WN* _array_ptr_alias_wn; /* store alias-wn for derefs of the array */ 00530 WN* _array_def_wn; /* stid that stores value returned by 00531 * __dsm_Alloc_Reshaped_Array for this array 00532 * (for locals) or ldid (for globals), if reshaped. 00533 */ 00534 00535 /* The following variables, dimsize/numprocs/chunksize for each dimension, 00536 * by rights belong within the DISTR_DIM class, but are declared here 00537 * since we want just one instance of each of those variables for a 00538 * distributed array, rather than one for each dact. 00539 */ 00540 SYMBOL** _dimsize; /* pointer to symbol containing block dim size*/ 00541 SYMBOL** _numprocs; /* pointer to symbol that contains 00542 * the number of procs in this dimension 00543 */ 00544 SYMBOL* _array_common; /* symbol for a reshaped array in a common 00545 * (the new location). 00546 */ 00547 WN* _array_common_alias_wn; /* WN storing alias for reshaped common array 00548 * (the new location). 00549 */ 00550 DYN_ARRAY<WN*>* _dimsize_wn; /* stmt wns that define _dimsize (for locals) 00551 * or an ldid of _dimsize (for globals) 00552 */ 00553 DYN_ARRAY<WN*>* _numprocs_wn; /* stmt wns that define _numprocs (for locals) 00554 * or an ldid of _numprocs (for globals) 00555 */ 00556 TY_IDX _orig_ty; /* the original TY entry for the array */ 00557 00558 DISTR_ARRAY_DA _dact_da; /* distribute DACTs */ 00559 DISTR_ARRAY_DA _redistr_da; /* redistribute DACTs */ 00560 DISTR_ARRAY_DA _gen_redistr_da; /* redistribute DACTs collected 00561 * after rest of LNO, during lego-gen 00562 * phase. 00563 */ 00564 BOOL _small_index; /* TRUE if all indices fit in 32-bits,else FALSE */ 00565 ST* _hoist_proc_array; /* local array */ 00566 INT _hoist_proc_index; /* last value already used */ 00567 WN *_hoist_proc_alias; /* store aliasing WN for hoist_proc */ 00568 DISTR_INFO* _buddy_dinfo; /* a buddy conforming dinfo, if any */ 00569 public: 00570 DISTR_INFO (mBOOL isreshaped, INT numdim, SYMBOL* array); 00571 ~DISTR_INFO (); 00572 00573 BOOL Small_Index () const { return _small_index; } 00574 mBOOL IsReshaped() const { return _isreshaped; } 00575 mBOOL IsDynamic() const { return _isdynamic; } 00576 void Set_Dynamic() { _isdynamic = TRUE; } 00577 INT Num_Dim() const { return _num_dim; } 00578 SYMBOL* Array() const { return _array; } 00579 ST* Array_ST() const { return _array->St(); } 00580 ST* Dart_ST() const { return _dart_st; } 00581 00582 void Find_Alloca (); 00583 WN* Load_Distr_Array (); 00584 WN* Load_New_Distr_Array (); 00585 SYMBOL* Array_Common_Symbol() const { return _array_common; } 00586 void Set_Array_Alias_WN (WN* wn) { _array_alias_wn = wn; } 00587 WN* Get_Array_Alias_WN () { return _array_alias_wn; } 00588 void Set_Array_Ptr_Alias_WN (WN* wn) { _array_ptr_alias_wn = wn; } 00589 WN* Get_Array_Ptr_Alias_WN () { return _array_ptr_alias_wn; } 00590 void Set_Array_Def_WN (WN* wn) { _array_def_wn = wn; } 00591 void Add_Array_Use_WN (WN* use_wn) { 00592 if (_array_def_wn == NULL) _array_def_wn = Current_Func_Node; 00593 Du_Mgr->Add_Def_Use (_array_def_wn, use_wn); 00594 } 00595 // the following is used just for debugging 00596 WN* Get_Array_Def_WN () { return _array_def_wn; } 00597 00598 WN* DART_Ldid (ST* st = NULL); 00599 void DART_Stid (WN* stid_wn, ST* st = NULL); 00600 void DART_Ptr_Ref(WN* wn, ST* st = NULL); 00601 00602 SYMBOL* Get_Dimsize (INT i) const { return _dimsize[i]; } 00603 SYMBOL* Get_Numprocs (INT i) const { return _numprocs[i]; } 00604 WN* Numprocs(INT dim); 00605 WN* Dimsize(INT dim); 00606 WN* Chunksize(INT dim); 00607 00608 void Numprocs_Ldid (INT dim, WN* ldid_wn); 00609 void Numprocs_Stid (INT dim, WN* stid_wn); 00610 void Dimsize_Ldid (INT dim, WN* ldid_wn); 00611 void Dimsize_Stid (INT dim, WN* stid_wn); 00612 00613 /* Return a WHIRL array node, a sample array reference to this array */ 00614 WN* Get_Array_Dim_Size (INT dim); 00615 00616 void Add_Dact (DISTR_ARRAY* dact) { 00617 _dact_da[_dact_da.Newidx()] = dact; 00618 dact->Set_Dinfo(this); 00619 FmtAssert (!_isreshaped || (_dact_da.Elements() == 1), 00620 ("Multiple reshapes (%s) not allowed", ST_name(_array->St()))); 00621 } 00622 INT Num_Dact () const { return _dact_da.Elements(); } 00623 DISTR_ARRAY* Get_Dact (INT i) const { return _dact_da[i]; } 00624 00625 void Add_Redistr (DISTR_ARRAY* redistr) { 00626 _redistr_da[_redistr_da.Newidx()] = redistr; 00627 redistr->Set_Dinfo(this); 00628 FmtAssert (!_isreshaped, ("Cannot redistribute a reshaped array (%s)", 00629 ST_name(_array->St()))); 00630 } 00631 INT Num_Redistr () const { return _redistr_da.Elements(); } 00632 DISTR_ARRAY* Get_Redistr (INT i) const { return _redistr_da[i]; } 00633 00634 void Add_Gen_Redistr (DISTR_ARRAY* redistr) { 00635 _gen_redistr_da[_gen_redistr_da.Newidx()] = redistr; 00636 redistr->Set_Dinfo(this); 00637 FmtAssert (!_isreshaped, ("Cannot redistribute a reshaped array (%s)", 00638 ST_name(_array->St()))); 00639 } 00640 INT Num_Gen_Redistr () const { return _gen_redistr_da.Elements(); } 00641 DISTR_ARRAY* Get_Gen_Redistr (INT i) const { return _gen_redistr_da[i]; } 00642 00643 void Set_Orig_TY(TY_IDX ty) { _orig_ty = ty; } 00644 TY_IDX Orig_TY() const { return _orig_ty; } 00645 00646 ST* Hoist_Proc_Array() const { return _hoist_proc_array; } 00647 INT Hoist_Proc_Next_Offset() { 00648 Is_True (_hoist_proc_array, ("Hoist-Next-Offset, but not initialized\n")); 00649 ++_hoist_proc_index; 00650 return (_hoist_proc_index* 00651 TY_size(TY_AR_etype(ST_type(_hoist_proc_array)))); 00652 } 00653 void Hoist_Proc_Init (TYPE_ID type); 00654 void Hoist_Proc_Alias (WN* wn) { 00655 if (_hoist_proc_alias == NULL) { 00656 _hoist_proc_alias = wn; 00657 Create_unique_pointer_alias (Alias_Mgr, 00658 _hoist_proc_array, NULL, wn); 00659 } 00660 else { 00661 Copy_alias_info (Alias_Mgr, _hoist_proc_alias, wn); 00662 } 00663 } 00664 void Set_Buddy (DISTR_INFO* dinfo) { 00665 Is_True (dinfo != this, 00666 ("Set_Buddy: trying to set self to buddy")); 00667 _buddy_dinfo = dinfo; 00668 } 00669 00670 void Print (FILE* fp) const { 00671 INT i; 00672 fprintf (fp, "Distributed array: "); _array->Print (fp); 00673 fprintf (fp, " %d dimensions, %s\n", _num_dim, 00674 (_isreshaped ? "reshaped" : "not reshaped")); 00675 fprintf (fp, "Compile-time distributions (%d)\n", _dact_da.Elements()); 00676 for (i=0; i<_dact_da.Elements (); i++) { 00677 fprintf (fp, "Distribution number %d\n", i); 00678 _dact_da[i]->Print (fp); 00679 } 00680 fprintf (fp, "Redistributions (%d)\n", _redistr_da.Elements()); 00681 for (i=0; i<_redistr_da.Elements (); i++) { 00682 fprintf (fp, "Redistribution number %d\n", i); 00683 _redistr_da[i]->Print (fp); 00684 } 00685 } 00686 }; 00687 00688 class DISTR_GLOBAL_INFO { 00689 TY_IDX _orig_ty; 00690 DISTR_GLOBAL_INFO (void); 00691 DISTR_GLOBAL_INFO (const DISTR_GLOBAL_INFO&); 00692 DISTR_GLOBAL_INFO* operator= (const DISTR_GLOBAL_INFO&); 00693 public: 00694 DISTR_GLOBAL_INFO(TY_IDX ty) { _orig_ty = ty; } 00695 TY_IDX Get_TY () { return _orig_ty; } 00696 }; 00697 00698 typedef HASH_TABLE<ST*, DISTR_INFO*> DA_HASH_TABLE; 00699 extern DA_HASH_TABLE *da_hash; 00700 typedef STACK<DISTR_INFO*> DA_STACK; 00701 extern DA_STACK *da_stack; 00702 typedef HASH_TABLE<ST*, DISTR_GLOBAL_INFO*> DA_GLOBAL_HASH_TABLE; 00703 extern DA_GLOBAL_HASH_TABLE* da_global; 00704 00705 extern void Read_Distr_Pragmas (WN* func_nd); 00706 extern WN *Read_Pragma_Distribute(WN *pwn); 00707 extern WN* Read_Pragma_Redistribute (WN* pwn, BOOL gen_phase = FALSE); 00708 extern WN* Load_Distr_Array (ST* array_st); 00709 extern WN* Numprocs (ST* array_st, INT dim, BOOL inside_loop, WN** block_wn); 00710 00711 #endif // _LEGO_PRAGMA_INCLUDED_
1.5.6