-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreatCL1.cpp
More file actions
151 lines (98 loc) · 3.51 KB
/
creatCL1.cpp
File metadata and controls
151 lines (98 loc) · 3.51 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#include "rpucfg.h"
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <algorithm>
#if 0
int RPUConfig::createCL1File(const String &fileName){
// Create file
std::ofstream CL1File(fileName.c_str());
assert(CL1File);
const String & graphName = dfgGraph.name();
// uppercase of name
String GRAPHNAME = graphName;
std::transform(GRAPHNAME.begin(), GRAPHNAME.end(),
GRAPHNAME.begin(), ::toupper);
CL1File<<
"/******************************************************\n"
" * This file is generated by RPUCompiler automatically.\n"
" * ----------------------------------------------------\n"
" * This file include CL1 context to initialize GCGM. \n"
" */\n\n"
"#ifndef "<<GRAPHNAME<<"_CL1_H\n"
"#define "<<GRAPHNAME<<"_CL1_H\n"<<std::endl;
CL1File<<"\n#define "<<GRAPHNAME<<"_CL1_SIZE\t"
<<std::dec<<CL1Context.size()<<";\n\n";
int cl1SeqNo = 0;
Vector<Vector<reg32> >::iterator cl1Iter;
for(cl1Iter = CL1Context.begin();
cl1Iter != CL1Context.end(); ++ cl1Iter, ++ cl1SeqNo){
Vector<reg32> & curCL1Context = * cl1Iter;
const String & graphName = dfgGraph.name();
// Print context
//---------------------------------------------------------
std::size_t cl1Size = curCL1Context.size();
CL1File<<"\n#define "<<GRAPHNAME<<"_CL1_"<<cl1SeqNo
<<"_SIZE\t"<<std::dec<<cl1Size<<";\n\n";
CL1File<<"unsigned int "<<graphName<<"_CL1_ctx_"
<<cl1SeqNo<<" [] = {";
CL1File.fill('0');
std::size_t cl1size = curCL1Context.size();
for(std::size_t i =0; i <cl1size; ++ i){
CL1File<<"\n\t\t0x"<<std::setw(8)<<std::hex<<curCL1Context[i];
if( i + 1 != cl1size)CL1File<<",";
}
CL1File<<"\n};\n\n"<<std::endl;
}
CL1File<<"#endif"<<std::endl;
return 0;
}
#endif
int RPUConfig::createCL1File(const String &fileName,const String &C_fileName){
// Create file
std::ofstream CL1File(fileName.c_str());
std::ofstream C_CL1File(C_fileName.c_str());
assert(CL1File);
assert(C_CL1File);
//const String & graphName = dfgGraph.name();
// uppercase of name
//String GRAPHNAME = graphName;
//std::transform(GRAPHNAME.begin(), GRAPHNAME.end(),
// GRAPHNAME.begin(), ::toupper);
C_CL1File<<"[Context Group Memory]\n";
int cl1SeqNo = 0;
Vector<Vector<reg32> >::iterator cl1Iter;
std::size_t cl1SizeCount;
cl1SizeCount=0;
for(cl1Iter = CL1Context.begin(); cl1Iter != CL1Context.end(); ++ cl1Iter)
{
Vector<reg32> & curCL1Context = * cl1Iter;
cl1SizeCount += curCL1Context.size();
}
C_CL1File<<"Group Cnt="<<std::dec<<cl1SizeCount<<"\n\n";
cl1SizeCount=0;
for(cl1Iter = CL1Context.begin(); cl1Iter != CL1Context.end(); ++ cl1Iter, ++ cl1SeqNo)
{
Vector<reg32> & curCL1Context = * cl1Iter;
const String & graphName = dfgGraph.name();
// Print context
//---------------------------------------------------------
std::size_t cl1Size = curCL1Context.size();
//CL1File<<"\n#define "<<GRAPHNAME<<"_CL1_"<<cl1SeqNo<<"_SIZE\t"<<std::dec<<cl1Size<<";\n\n";
CL1File.fill('0');
C_CL1File.fill('0');
std::size_t cl1size = curCL1Context.size();
for(std::size_t i =0; i <cl1size; ++ i)
{
CL1File<<std::setw(8)<<std::hex<<curCL1Context[i]<<"\n";
C_CL1File<<"GroupWord["<<std::dec<<(i+cl1SizeCount)<<"]=0x"<<std::setw(8)<<std::hex<<curCL1Context[i]<<";\n";
}
cl1SizeCount +=cl1size;
// CL1File<<"\n\n"<<std::endl;
}
//CL1File<<"#endif"<<std::endl;
CL1File.close();
C_CL1File.close();
return 0;
}