blob: b7d713216e8259837a8d09f80fa5a64458d65d22 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
#include <iostream>
#include "decudaInstList.h"
#include <stdio.h>
#include<fstream>
using namespace std;
decudaInstList *g_instList = new decudaInstList();
decudaInstList *g_headerList = new decudaInstList();
int yyparse();
extern "C" FILE *yyin;
int ptx_parse();
extern "C" FILE *ptx_in;
FILE *bin_in;
FILE *ptxplus_out;
void output(const char * text)
{
fprintf(ptxplus_out, text);
}
std::string fileToString(const char * fileName) {
ifstream fileStream(fileName, ios::in);
string text, line;
while(getline(fileStream,line)) {
text += (line + "\n");
}
fileStream.close();
return text;
}
int main(int argc, char* argv[])
{
if(argc != 5)
{
cout << "Usage: decuda_to_ptxplus [decuda filename] [ptx filename] [bin filename] [ptxplus output filename]\n";
return 0;
}
const char *decudaFilename = argv[1];
const char *ptxFilename = argv[2];
const char *binFilename = argv[3];
const char *ptxplusFilename = argv[4];
//header_in = fopen( ptxFilename, "r" );
ptx_in = fopen( ptxFilename, "r" );
yyin = fopen( decudaFilename, "r" );
bin_in = fopen( binFilename, "r" );
ptxplus_out = fopen( ptxplusFilename, "w" );
fileToString(binFilename);
printf("RUNNING decuda2ptxplus ...\n");
// Parse original ptx
ptx_parse();
// Copy real tex list from ptx to ptxplus instruction list
g_instList->setRealTexList(g_headerList->getRealTexList());
// Insert constant memory from bin file
g_instList->readConstMemoryFromBinFile(fileToString(binFilename));
// Insert global memory from bin file
g_instList->readGlobalMemoryFromBinFile(fileToString(binFilename));
// Parse decuda output
yyparse();
printf("END RUN\n");
// Print ptxplus
g_headerList->printHeaderInstList();
g_instList->printNewPtxList(g_headerList);
fclose(ptx_in);
fclose(yyin);
fclose(bin_in);
fclose(ptxplus_out);
printf("DONE. \n");
return 0;
}
|