Compare commits
3 Commits
1d82af702e
...
968491ee29
| Author | SHA1 | Date | |
|---|---|---|---|
| 968491ee29 | |||
|
|
11888f2ff9 | ||
| ed34da415a |
@@ -54,6 +54,7 @@ int getLastLabelId();
|
||||
int isItInSection();
|
||||
int Init_Tool_Box();
|
||||
void Message();
|
||||
|
||||
PTR_BFND rec_num_near_search();
|
||||
PTR_BFND Redo_Bif_Next_Chain_Internal();
|
||||
PTR_SYMB duplicateSymbol();
|
||||
@@ -82,6 +83,12 @@ int out_upper_case;
|
||||
int out_line_unlimit;
|
||||
int out_line_length; // out_line_length = 132 for -ffo mode; out_line_length = 72 for -uniForm mode
|
||||
PTR_SYMB last_file_symbol;
|
||||
struct file_symbol {
|
||||
char *fname;
|
||||
PTR_SYMB last_symb;
|
||||
struct file_symbol *next;
|
||||
} ;
|
||||
struct file_symbol *file_last_symbol = NULL;
|
||||
|
||||
static int CountNullBifNext = 0; /* for internal debugging */
|
||||
|
||||
@@ -94,7 +101,6 @@ enum typenode node_code_kind[LAST_CODE];
|
||||
char info_type[LAST_CODE][MAXFIELDTYPE];
|
||||
char info_symb[LAST_CODE][MAXFIELDSYMB];
|
||||
char general_info[LAST_CODE][MAXFIELDSYMB];
|
||||
|
||||
/*static struct bif_stack_level *stack_level = NULL;*/
|
||||
/*static struct bif_stack_level *current_level = NULL;*/
|
||||
|
||||
@@ -247,6 +253,24 @@ char* mymalloc(int size)
|
||||
return pt1;
|
||||
}
|
||||
|
||||
PTR_SYMB FileLastSymbol(char *file_name)
|
||||
{
|
||||
struct file_symbol *fsl;
|
||||
for(fsl=file_last_symbol; fsl; fsl=fsl->next)
|
||||
if(!strcmp(file_name, fsl->fname))
|
||||
return fsl->last_symb;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void addFileSymbolList(char *file_name, PTR_SYMB symb)
|
||||
{
|
||||
struct file_symbol *fsl;
|
||||
fsl = (struct file_symbol *) xmalloc(sizeof (struct file_symbol));
|
||||
fsl->last_symb = symb;
|
||||
fsl->fname = file_name;
|
||||
fsl->next = file_last_symbol;
|
||||
file_last_symbol = fsl;
|
||||
}
|
||||
/***************** Provides infos on nodes ********************************
|
||||
* *
|
||||
* based on the table info in include dir *.def *
|
||||
@@ -549,6 +573,7 @@ void Message(char *s, int l)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
/* A set of functions for dealing with a free list for low_level node */
|
||||
/***************************************************************************/
|
||||
@@ -1203,8 +1228,7 @@ int Init_Tool_Box()
|
||||
number_of_ll_node = CUR_FILE_NUM_LLNDS() + 1;
|
||||
number_of_bif_node = CUR_FILE_NUM_BIFS() + 1;
|
||||
number_of_symb_node = CUR_FILE_NUM_SYMBS() + 1;
|
||||
last_file_symbol = CUR_FILE_CUR_SYMB(); /* podd 23.06.15 */
|
||||
|
||||
addFileSymbolList(CUR_FILE_NAME(), CUR_FILE_CUR_SYMB()); /* podd 01.03.24 */
|
||||
if (CUR_FILE_NAME()) strcpy(Current_File_name, CUR_FILE_NAME());
|
||||
if (ToolBOX_INIT)
|
||||
return 0;
|
||||
|
||||
@@ -736,7 +736,8 @@ void Init_Unparser()
|
||||
/* set the first tabulation */
|
||||
TabNumber = 1;
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Parser_Initiated != C_Initialized)
|
||||
{
|
||||
@@ -748,6 +749,9 @@ void Init_Unparser()
|
||||
#include"unparseC++.def"
|
||||
#undef DEFNODECODE
|
||||
Parser_Initiated = C_Initialized;
|
||||
/* set the first tabulation */
|
||||
TabNumber = 0;
|
||||
|
||||
/* init precedence table of operators for C++ */
|
||||
for(i=BIT_COMPLEMENT_OP - EQ_OP; i<=RSHIFT_ASSGN_OP-EQ_OP;i++)
|
||||
precedence_C[i] = precedence2_C[i-BIT_COMPLEMENT_OP+EQ_OP];
|
||||
|
||||
@@ -83,11 +83,14 @@ void InitializeACC()
|
||||
type_CudaIndexType = NULL;
|
||||
type_with_len_DvmType = NULL;
|
||||
declaration_cmnt = NULL;
|
||||
indexType_int = indexType_long = indexType_llong = NULL;
|
||||
dvmh_targets = options.isOn(NO_CUDA) ? HOST_DEVICE : HOST_DEVICE | CUDA_DEVICE;
|
||||
|
||||
SpecialSymbols.insert(std::pair<char, const char*>('\n', "\\n\"\n\""));
|
||||
SpecialSymbols.insert(std::pair<char, const char*>('"', "\\\""));
|
||||
SpecialSymbols.insert(std::pair<char, const char*>('\\', "\\\\"));
|
||||
|
||||
InitializeAcrossACC();
|
||||
}
|
||||
|
||||
char *filenameACC()
|
||||
|
||||
@@ -40,15 +40,13 @@ void DeclarationCreateReductionBlocksAcross(int, SgExpression*);
|
||||
AnalyzeReturnGpuO1 analyzeLoopBody(int type);
|
||||
|
||||
// local static variables
|
||||
static SgSymbol *red_first;
|
||||
static bool declaration_include = true;
|
||||
static SgSymbol *red_first = NULL;
|
||||
static bool createBodyKernel = false;
|
||||
static bool createConvert_XY = true;
|
||||
static const int numLoopVars = 16;
|
||||
static bool ifReadLvlMode = false;
|
||||
static vector <stack <SgStatement*> > copyOfBody;
|
||||
static vector<SgSymbol*> allRegNames;
|
||||
static unsigned countOfCopies;
|
||||
static vector<ParamsForAllVariants> allVariants;
|
||||
|
||||
static const char *funcDvmhConvXYfortVer = " attributes(device) subroutine dvmh_convert_XY_int(x,y,Rx,Ry,slash,idx)\n implicit none\n integer ,value:: x\n integer ,value:: y\n integer ,value:: Rx\n integer ,value:: Ry\n integer ,value:: slash\n integer ,device:: idx \n \n if(slash .eq. 0) then\n if(Rx .eq. Ry) then\n if(x + y .lt. Rx) then\n idx = y + (1+x+y)*(x+y)/2\n else\n idx = Rx*(Rx-1)+x-(2*Rx-x-y-1)*(2*Rx-x-y-2)/2\n endif \n elseif(Rx .lt. Ry) then\n if(x + y .lt. Rx) then\n idx = y + ((1+x+y)*(x+y)) / 2\n elseif(x + y .lt. Ry) then\n idx = ((1+Rx)*Rx) / 2 + Rx - x - 1 + Rx * (x+y-Rx)\n else\n idx = Rx*Ry-Ry+y-(((Rx+Ry-y-x-1)*(Rx+Ry-y-x-2))/2)\n endif\n else\n if(x + y .lt. Ry) then\n idx = x + (1+x+y)*(x+y) / 2\n elseif(x + y .lt. Rx) then\n idx = (1+Ry)*Ry/2 + (Ry-y-1) + Ry * (x+y-Ry)\n else\n idx = Rx*Ry-Rx+x-((Rx+Ry-y-x-1)*(Rx+Ry-y-x-2)/2)\n endif\n endif\n else\n if(Rx .eq. Ry) then\n if(x + Rx-1-y .lt. Rx) then\n idx = Rx-1-y + (x+Rx-y)*(x+Rx-1-y)/2\n else\n idx = Rx*(Rx-1) + x - (Rx-x+y)*(Rx-x+y-1)/2\n endif\n elseif(Rx .lt. Ry) then\n if(x + Ry-1-y .lt. Rx) then \n idx = Ry-1-y + ((x+Ry-y)*(x+Ry-1-y)) / 2\n elseif(x + Ry-1-y .lt. Ry) then\n idx = ((1+Rx)*Rx)/2+Rx-x-1+Rx*(x+Ry-1-y-Rx)\n else\n idx = Rx*Ry-1-y-(((Rx+y-x)*(Rx+y-x-1))/2)\n endif\n else\n if(x + Ry-1-y .lt. Ry) then\n idx = x + (1+x+Ry-1-y)*(x+Ry-1-y)/2\n elseif(x + Ry-1-y .lt. Rx) then\n idx = (1+Ry)*Ry/2 + y + Ry * (x-y-1)\n else\n idx = Rx*Ry-Rx+x-((Rx+y-x)*(Rx+y-x-1)/2)\n endif\n endif\n endif\n end subroutine\n";
|
||||
@@ -58,6 +56,17 @@ static const char* fermiPreprocDir = "CUDA_FERMI_ARCH";
|
||||
// local variables
|
||||
SgStatement *kernelScope, *block;
|
||||
|
||||
void InitializeAcrossACC()
|
||||
{
|
||||
red_first = NULL;
|
||||
createBodyKernel = false;
|
||||
createConvert_XY = true;
|
||||
ifReadLvlMode = false;
|
||||
copyOfBody.clear();
|
||||
allRegNames.clear();
|
||||
allVariants.clear();
|
||||
}
|
||||
|
||||
static inline int pow(int n)
|
||||
{
|
||||
int tmp = 1;
|
||||
@@ -716,9 +725,6 @@ ArgsForKernel *Create_C_Adapter_Function_Across(SgSymbol *sadapter)
|
||||
{
|
||||
if (allVariants[i].acrossV != 1)
|
||||
ifOne = false;
|
||||
|
||||
if ((unsigned)allVariants[i].acrossV == countOfCopies + 1)
|
||||
countOfCopies++;
|
||||
}
|
||||
// set global if true
|
||||
if (ifOne)
|
||||
@@ -1787,11 +1793,8 @@ vector<ArgsForKernel> Create_C_Adapter_Function_Across_variants(SgSymbol *sadapt
|
||||
st_end = st_hedr->lexNext();
|
||||
fe = st_hedr->expr(0);
|
||||
first_exec = st_end;
|
||||
if (declaration_include)
|
||||
{
|
||||
if (declaration_cmnt == NULL)
|
||||
declaration_cmnt = "#include <cstdio>\n#define MIN(X,Y) ((X) < (Y) ? (X) : (Y))\n#define MAX(X,Y) ((X) > (Y) ? (X) : (Y))";
|
||||
declaration_include = false;
|
||||
}
|
||||
|
||||
mywarn(" end: create fuction header ");
|
||||
mywarn("start: create dummy argument list ");
|
||||
|
||||
@@ -82,6 +82,7 @@ extern "C" int out_upper_case;
|
||||
extern "C" int out_line_unlimit;
|
||||
extern "C" int out_line_length;
|
||||
extern "C" PTR_SYMB last_file_symbol;
|
||||
extern "C" PTR_SYMB FileLastSymbol(...);
|
||||
|
||||
Options options;
|
||||
|
||||
@@ -99,7 +100,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
FILE *fout = NULL;
|
||||
FILE *fout_cuf = NULL, *fout_C_cu = NULL, *fout_info = NULL; /*ACC*/
|
||||
const char *fout_name = "out.DVMH.f";
|
||||
const char *fout_name = NULL;
|
||||
char *fout_name_cuf; /*ACC*/
|
||||
char *fout_name_C_cu; /*ACC*/
|
||||
char *fout_name_info_C; /*ACC*/
|
||||
@@ -403,8 +404,8 @@ int main(int argc, char *argv[])
|
||||
// for call of function 'tpoint'
|
||||
//added one symbol to input-file name
|
||||
//printf("%s",fin_name); //!!! debug
|
||||
if(a_mode || project.numberOfFiles()>1)
|
||||
fout_name = doOutFileName(file->filename()); //project.fileName(id);
|
||||
if(!fout_name)
|
||||
fout_name = doOutFileName(file->filename());
|
||||
else if (fout_name && source_name && !strcmp(source_name, fout_name))
|
||||
{
|
||||
(void)fprintf(stderr, "Output file has the same name as source file\n");
|
||||
@@ -417,7 +418,7 @@ int main(int argc, char *argv[])
|
||||
fout_name_info_C = ChangeFto_info_C(fout_name); /*ACC*/
|
||||
|
||||
//set the last symbol of file
|
||||
last_file_symbol = CUR_FILE_CUR_SYMB(); //LastSymbolOfFile(file)->thesymb; //for low_level.c
|
||||
last_file_symbol = FileLastSymbol(file->filename()); //for low_level.c and not only
|
||||
initLibNames(); //for every file
|
||||
InitDVM(file); //for every file
|
||||
current_file = file; // global variable (used in SgTypeComplex)
|
||||
@@ -542,6 +543,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
fout_name = NULL;
|
||||
}
|
||||
|
||||
if (v_print)
|
||||
|
||||
@@ -1004,6 +1004,7 @@ SgStatement *doIfThenConstrForLoop_GPU(SgExpression *ref,SgStatement *endhost,Sg
|
||||
SgStatement *doIfThenConstrForLoop_GPU(SgExpression *ref,SgStatement *endhost,SgStatement *dowhile);
|
||||
SgSymbol *KernelSymbol(SgStatement *st_do);
|
||||
void Blocks_Off_Symbol();
|
||||
void InitializeACC();
|
||||
void InitializeAcrossACC();
|
||||
void InitializeInFuncACC();
|
||||
SgSymbol *GPUModuleSymb(SgStatement *global_st);
|
||||
|
||||
@@ -31,13 +31,13 @@ extern "C" int out_upper_case;
|
||||
extern "C" int out_line_unlimit;
|
||||
extern "C" int out_line_length;
|
||||
extern "C" PTR_SYMB last_file_symbol;
|
||||
extern "C" PTR_SYMB FileLastSymbol(...);
|
||||
|
||||
static int convertFile(int argc, char* argv[], const string& fileToConv,
|
||||
const set<string>& filesInProj, const set<string>& moduleDeclsInFiles)
|
||||
static int convertFile(int argc, char* argv[], const set<string>& filesInProj, const set<string>& moduleDeclsInFiles)
|
||||
{
|
||||
FILE* fout = NULL;
|
||||
FILE* fout_cuf = NULL, * fout_C_cu = NULL, * fout_info = NULL; /*ACC*/
|
||||
const char* fout_name = "out.DVMH.f";
|
||||
const char* fout_name = NULL;
|
||||
char* fout_name_cuf; /*ACC*/
|
||||
char* fout_name_C_cu; /*ACC*/
|
||||
char* fout_name_info_C; /*ACC*/
|
||||
@@ -54,6 +54,7 @@ static int convertFile(int argc, char* argv[], const string& fileToConv,
|
||||
while ((argc > 1) && (*argv)[0] == '-')
|
||||
{
|
||||
if ((*argv)[1] == 'o' && ((*argv)[2] == '\0')) {
|
||||
if (filesInProj.size() == 1)
|
||||
fout_name = argv[1];
|
||||
argv++;
|
||||
argc--;
|
||||
@@ -307,7 +308,8 @@ static int convertFile(int argc, char* argv[], const string& fileToConv,
|
||||
static int id = 0;
|
||||
|
||||
vector<char*> filesList;
|
||||
filesList.push_back((char*)fileToConv.c_str());
|
||||
for (auto& file : filesInProj)
|
||||
filesList.push_back((char*)file.c_str());
|
||||
|
||||
SgProject project((proj_name + to_string(id++)).c_str(), filesList.data(), filesList.size());
|
||||
|
||||
@@ -317,7 +319,7 @@ static int convertFile(int argc, char* argv[], const string& fileToConv,
|
||||
removeExecutableFromModuleDeclaration(&(project.file(z)), filesInProj, tmp);
|
||||
}
|
||||
|
||||
SgFile* file;
|
||||
SgFile* file = NULL;
|
||||
addNumberOfFileToAttribute(&project);
|
||||
|
||||
//----------------------------
|
||||
@@ -331,10 +333,12 @@ static int convertFile(int argc, char* argv[], const string& fileToConv,
|
||||
initF2C_FunctionCalls(); // for project, acc_f2c.cpp
|
||||
for (int id = project.numberOfFiles() - 1; id >= 0; id--)
|
||||
{
|
||||
file = &(project.file(id)); //file->unparsestdout();
|
||||
file = &(project.file(id));
|
||||
fin_name = new char[strlen(project.fileName(id)) + 2];
|
||||
sprintf(fin_name, "%s%s", project.fileName(id), " ");
|
||||
fout_name = doOutFileName(file->filename()); //project.fileName(id);
|
||||
|
||||
if (fout_name == NULL)
|
||||
fout_name = doOutFileName(file->filename());
|
||||
|
||||
if (fout_name && source_name && !strcmp(source_name, fout_name))
|
||||
{
|
||||
@@ -342,12 +346,14 @@ static int convertFile(int argc, char* argv[], const string& fileToConv,
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("convert %d to %s\n", id, fout_name);
|
||||
|
||||
fout_name_cuf = ChangeFtoCuf(fout_name); /*ACC*/
|
||||
fout_name_C_cu = ChangeFto_C_Cu(fout_name); /*ACC*/
|
||||
fout_name_info_C = ChangeFto_info_C(fout_name); /*ACC*/
|
||||
|
||||
//set the last symbol of file
|
||||
last_file_symbol = CUR_FILE_CUR_SYMB();
|
||||
last_file_symbol = FileLastSymbol(file->filename());
|
||||
initLibNames(); //for every file
|
||||
InitDVM(file); //for every file
|
||||
current_file = file; // global variable (used in SgTypeComplex)
|
||||
@@ -402,7 +408,22 @@ static int convertFile(int argc, char* argv[], const string& fileToConv,
|
||||
UnparseTo_CufAndCu_Files(file, fout_cuf, fout_C_cu, fout_info);
|
||||
|
||||
const string fileN = file->filename();
|
||||
hideUnnecessary(file, fileN, moduleDeclsInFiles, true);
|
||||
set<SgStatement*> toRemove;
|
||||
|
||||
for (SgStatement* st = file->firstStatement(); st; st = st->lexNext())
|
||||
{
|
||||
if (st->fileName() != fileN)
|
||||
{
|
||||
if (st->variant() == MODULE_STMT && moduleDeclsInFiles.find(st->fileName()) != moduleDeclsInFiles.end())
|
||||
{
|
||||
toRemove.insert(st);
|
||||
st = st->lastNodeOfStmt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& toRem : toRemove)
|
||||
toRem->extractStmt();
|
||||
|
||||
if (unparse_functions)
|
||||
UnparseFunctionsOfFile(file, fout);
|
||||
@@ -434,7 +455,7 @@ static int convertFile(int argc, char* argv[], const string& fileToConv,
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
fout_name = NULL;
|
||||
}
|
||||
|
||||
if (v_print)
|
||||
@@ -467,11 +488,11 @@ void convertFiles(int argc, char* argv[], const char* proj_name)
|
||||
|
||||
const string fileText = readFileToStr(proj_name);
|
||||
vector<string> files;
|
||||
set<string> filesinSet;
|
||||
set<string> filesInSet;
|
||||
splitString(fileText, '\n', files);
|
||||
|
||||
for (auto& file : files)
|
||||
filesinSet.insert(file);
|
||||
filesInSet.insert(file);
|
||||
|
||||
map<string, set<string>> moduleUsesByFile;
|
||||
map<string, string> moduleDecls;
|
||||
@@ -482,9 +503,9 @@ void convertFiles(int argc, char* argv[], const char* proj_name)
|
||||
moduleDeclsInFiles.insert(elem.second);
|
||||
|
||||
int codes = 0;
|
||||
for (auto& file : files)
|
||||
//for (auto& file : files)
|
||||
{
|
||||
codes += convertFile(args_v.size() - 1, args_v.data(), file, filesinSet, moduleDeclsInFiles);
|
||||
codes += convertFile(args_v.size(), args_v.data(), filesInSet, moduleDeclsInFiles);
|
||||
|
||||
cur_node = node_list = NULL;
|
||||
InitializeTable();
|
||||
|
||||
@@ -212,7 +212,8 @@ void InitPassesDependencies(map<passes, vector<passes>> &passDepsIn, set<passes>
|
||||
|
||||
Pass(BUILD_IR) <= Pass(SUBST_EXPR_RD) <= Pass(SUBST_EXPR_RD_AND_UNPARSE);
|
||||
|
||||
list({ LOOP_ANALYZER_DATA_DIST_S1, SUBST_EXPR_RD } ) <= Pass(PRIVATE_REMOVING_ANALYSIS) <= Pass(REVERT_SUBST_EXPR_RD) <= Pass(PRIVATE_REMOVING);
|
||||
list({ LOOP_ANALYZER_DATA_DIST_S1, SUBST_EXPR_RD } ) <= Pass(PRIVATE_REMOVING_ANALYSIS);
|
||||
list({ PRIVATE_REMOVING_ANALYSIS, REVERT_SUBST_EXPR_RD }) <= Pass(PRIVATE_REMOVING);
|
||||
|
||||
Pass(RESTORE_LOOP_FROM_ASSIGN) <= list({ SUBST_EXPR_AND_UNPARSE, SUBST_EXPR_RD_AND_UNPARSE });
|
||||
|
||||
|
||||
@@ -271,7 +271,7 @@ static int reverseVar(SgStatement* st)
|
||||
static map<SgStatement*, map<int, set<string>>> insertedIncludes;
|
||||
static set<SgFile*> genVersionDone;
|
||||
|
||||
set<int> hideUnnecessary(SgFile* file, const string& fileN, const set<string>& moduleDeclsInFiles, bool dontReplaceIncludes)
|
||||
static set<int> hideUnnecessary(SgFile* file, const string& fileN, const set<string>& moduleDeclsInFiles, bool dontReplaceIncludes)
|
||||
{
|
||||
set<int> changedVars;
|
||||
for (SgStatement* st = file->firstStatement(); st; st = st->lexNext())
|
||||
|
||||
@@ -11,7 +11,6 @@ SgStatement* declaratedInStmt(SgSymbol *toFind, std::vector<SgStatement*> *allDe
|
||||
#include "DefUseList.h"
|
||||
#include "CommonBlock.h"
|
||||
|
||||
std::set<int> hideUnnecessary(SgFile* file, const std::string& fileN, const std::set<std::string>& moduleDeclsInFiles, const bool dontReplaceIncludes);
|
||||
std::string removeIncludeStatsAndUnparse(SgFile *file, const char *fileName, const char *fout, std::set<std::string> &allIncludeFiles, bool outFree, const std::map<std::string, std::set<std::string>> &moduleUsesByFile, const std::map<std::string, std::string>& moduleDelcs, const std::map<SgStatement*, std::vector<SgStatement*>>& exctactedModuleStats, bool toString, bool dontReplaceIncls = false);
|
||||
SgSymbol* findSymbolOrCreate(SgFile *file, const std::string toFind, SgType *type = NULL, SgStatement *scope = NULL);
|
||||
void recExpressionPrint(SgExpression *exp);
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#define VERSION_SPF "2286"
|
||||
#define VERSION_SPF "2287"
|
||||
|
||||
Reference in New Issue
Block a user