#pragma once #include "acc_data.h" struct SageStOp { SgForStmt *loop_op; SgStatement *comment_op; SageStOp *inner_loops; SageStOp *next; int count_inner_loops; int line_code; int numChList1; int numChList2; int depth; int LoopNest; }; struct SageSymbols { SgSymbol *symb; int len; SageSymbols *next; int across_left; int across_right; }; struct SageArrayIdxs { SageSymbols **symb; int dim; int read_write; SgExpression *array_expr; SageArrayIdxs *next; }; struct Templates { SageSymbols *first; int count; int read_write; int count_write_read; Templates *next; }; struct SageAcrossInfo { SageStOp *Op; SageArrayIdxs *idx; SageAcrossInfo *next; }; struct ArgsForKernel { SgStatement *st_header; std::list symb; std::list nSymb; std::list sizeVars; std::list acrossS; std::list notAcrS; std::list idxAcross; std::list idxNotAcross; std::vector otherVars; std::vector arrayNames; std::vector otherVarsForOneTh; std::vector baseIdxsInKer; SgSymbol *cond_; std::vector steps; }; /*struct GetXYInfo { std::vector AllExp; SgSymbol *varName; char *arrayName; long type; int placeF; int placeS; };*/ /*struct TransformInfo { std::vector arrayNames; std::vector firstIdxs; std::vector secondIdxs; bool exist(char *name); bool find_in_exprs(SgSymbol*, SgSymbol*, char*, SgExpression*); bool find_add(SgSymbol*, SgSymbol*, char*); void getIdxs(char*, int&, int&); };*/ struct ParamsForAllVariants { SgSymbol *s_adapter; SgSymbol *s_kernel_symb; int loopV; int acrossV; int allDims; SageSymbols **loopSymb; SageSymbols **loopAcrossSymb; char *nameOfNewSAdapter; char *nameOfNewKernelSymb; int type; }; struct Bound { int L; int R; bool exL; bool exR; bool ifDdot; SgExpression *additionalExpr; }; struct BestPattern { std::vector what; std::vector bounds; SgExpression *bestPatt; int count_of_pattern; }; struct Pattern { int count_read_op; int count_write_op; SgExpression *symbs; }; struct AnalyzeStat { SgSymbol *replaceSymbol; int ifHasDim; SgSymbol *name_of_array; SgExpression *ex_name_of_array; std::vector patterns; }; // struct acrossInfo { char *nameOfArray; SgSymbol *symbol; int allDim; int acrossPos; int widthL; int widthR; int acrossNum; std::vector dims; std::vector symbs; }; struct newInfo { SgSymbol *newArray; std::vector dimSize; std::vector loadsBeforePlus; std::vector loadsInForPlus; std::vector loadsBeforeMinus; std::vector loadsInForMinus; std::vector stores; std::vector swapsDown; std::vector swapsUp; }; // end // block struct Group { char *strOfmain; // SgExpression *mainPattern; std::vector inGroup; std::vector len; std::vector sortLen; newInfo replaceInfo; // replace info with all needed loads and swaps for optimization }; struct PositionGroup { std::map tableReplace; // table of mapping new private variables to distributed arrays for replacing in loop body std::map tableNewVars; // table of new private variables that is needed to add in cuda kernel int position; // position of fixed variable in distributed loop, index 0 corresponds to the first variable. SgExpression *idxInPos; // std::vector allPosGr; // all groups of array access patterns with fixed loop variables, which is distributed }; struct ArrayGroup { SgSymbol *arrayName; // name of distribute array std::vector allGroups; // all groups, where one loop variable is fixed }; // end of block struct LoopInfo { std::vector loopSymbols; std::vector lowBounds; std::vector highBounds; std::vector steps; int lineNumber; }; struct ArrayIntents { std::vector arrayList; std::vector intent; }; struct AnalyzeReturnGpuO1 { std::vector allStat; std::vector bestPatterns; std::vector allArrayGroup; }; // functions SgExpression* findDirect(SgExpression*, int); //SageArrayIdxs* GetIdxInParDir(SgExpression*, SgExpression*); SageAcrossInfo* GetLoopsWithParAndAcrDir(); SageSymbols *GetSymbInParalell(int*, SgExpression*); int GetIdxPlaceInParDir(SageSymbols*, SgSymbol*);