-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSConscript
More file actions
281 lines (230 loc) · 10.8 KB
/
SConscript
File metadata and controls
281 lines (230 loc) · 10.8 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
#! /bin/python
################################################################################
# \file SConscript
# \author Naila Farooqui <naila@cc.gatech.edu>
# \date Monday June 25, 2012
# \brief The SCons master build script for Lynx (modified the one from Ocelot)
################################################################################
import os
import inspect
from subprocess import call
#
#
## The script begins here
# try to import an environment first
try:
Import('env')
except:
try:
exec open("../scripts/which.py")
prefix = '../'
except:
exec open("scripts/which.py")
prefix = './'
exec open(prefix + "scripts/build_environment.py")
env = Environment()
# find all source files in the source tree
sources = []
intermediate_headers = []
directories = [ 'lynx/analysis/implementation',
'lynx/api/implementation',
'lynx/cuda/implementation',
'lynx/instrumentation/implementation',
'lynx/transforms/implementation',
'lynx/translator/implementation',
'lynx/trace/implementation',
'hydrazine/interface',
'hydrazine/implementation']
# Ocelot dependencies
ocelot_dep = [ 'ocelot/analysis/implementation/Analysis.cpp',
'ocelot/analysis/implementation/BranchInfo.cpp',
'ocelot/analysis/implementation/ControlTree.cpp',
'ocelot/analysis/implementation/DataflowGraph.cpp',
'ocelot/analysis/implementation/DirectionalGraph.cpp',
'ocelot/analysis/implementation/DivergenceAnalysis.cpp',
'ocelot/analysis/implementation/DivergenceGraph.cpp',
'ocelot/analysis/implementation/DominatorTree.cpp',
'ocelot/analysis/implementation/PostdominatorTree.cpp',
'ocelot/analysis/implementation/SSAGraph.cpp',
'ocelot/cuda/implementation/FatBinaryContext.cpp',
'ocelot/ir/implementation/ControlFlowGraph.cpp',
'ocelot/ir/implementation/Dim3.cpp',
'ocelot/ir/implementation/Global.cpp',
'ocelot/ir/implementation/Instruction.cpp',
'ocelot/ir/implementation/IRKernel.cpp',
'ocelot/ir/implementation/Kernel.cpp',
'ocelot/ir/implementation/Local.cpp',
'ocelot/ir/implementation/Module.cpp',
'ocelot/ir/implementation/Parameter.cpp',
'ocelot/ir/implementation/PTXInstruction.cpp',
'ocelot/ir/implementation/PTXKernel.cpp',
'ocelot/ir/implementation/PTXOperand.cpp',
'ocelot/ir/implementation/PTXStatement.cpp',
'ocelot/ir/implementation/Texture.cpp',
'ocelot/parser/implementation/PTXLexer.cpp',
'ocelot/parser/implementation/PTXParser.cpp',
'ocelot/transforms/implementation/Pass.cpp',
'ocelot/transforms/implementation/PassManager.cpp',
'ocelot/transforms/implementation/ReadableLayoutPass.cpp' ]
ocelot_dep_headers = [ 'ocelot/analysis/interface/Analysis.h',
'ocelot/analysis/interface/AnalysisFactory.h',
'ocelot/analysis/interface/BranchInfo.h',
'ocelot/analysis/interface/ControlTree.h',
'ocelot/analysis/interface/DataflowGraph.h',
'ocelot/analysis/interface/DirectionalGraph.h',
'ocelot/analysis/interface/DivergenceAnalysis.h',
'ocelot/analysis/interface/DivergenceGraph.h',
'ocelot/analysis/interface/DominatorTree.h',
'ocelot/analysis/interface/PostdominatorTree.h',
'ocelot/analysis/interface/SSAGraph.h',
'ocelot/cuda/interface/FatBinaryContext.h',
'ocelot/cuda/interface/cudaFatBinary.h',
'ocelot/ir/interface/ControlFlowGraph.h',
'ocelot/ir/interface/Dim3.h',
'ocelot/ir/interface/Global.h',
'ocelot/ir/interface/Instruction.h',
'ocelot/ir/interface/IRKernel.h',
'ocelot/ir/interface/Kernel.h',
'ocelot/ir/interface/Local.h',
'ocelot/ir/interface/Module.h',
'ocelot/ir/interface/Parameter.h',
'ocelot/ir/interface/PTXEmitter.h',
'ocelot/ir/interface/PTXInstruction.h',
'ocelot/ir/interface/PTXKernel.h',
'ocelot/ir/interface/PTXOperand.h',
'ocelot/ir/interface/PTXStatement.h',
'ocelot/ir/interface/Texture.h',
'ocelot/parser/interface/Parser.h',
'ocelot/parser/interface/PTXLexer.h',
'ocelot/parser/interface/PTXParser.h',
'ocelot/transforms/interface/Pass.h',
'ocelot/transforms/interface/PassFactory.h',
'ocelot/transforms/interface/PassManager.h',
'ocelot/transforms/interface/ReadableLayoutPass.h' ]
ocelot_dir = ['ocelot/analysis/implementation', 'ocelot/analysis/interface',
'ocelot/cuda/implementation', 'ocelot/cuda/interface',
'ocelot/ir/implementation', 'ocelot/ir/interface',
'ocelot/parser/implementation', 'ocelot/parser/interface',
'ocelot/transforms/implementation', 'ocelot/transforms/interface']
# find all flex/bison sources
flex_sources = ['ocelot/parser/implementation/ptx.ll']
bison_sources = ['ocelot/parser/implementation/ptxgrammar.yy']
def buildCJIT():
#Create variables out of shell commands
cercs_env = "cd c-jit/cercs_env; ./configure && make && sudo make install"
atl = "cd c-jit/atl; ./configure && make && sudo make install"
fm = "cd c-jit/ffs/fm; ./configure && make && sudo make install"
dill = "cd c-jit/dill; ./configure && make && sudo make install"
cod = "cd c-jit/ffs/cod; ./configure && make && sudo make install"
#Places variables into a list/array
cmds = [cercs_env, atl, fm, dill, cod]
libs = ["/usr/local/lib/libcercs_env.so", "/usr/local/lib/libatl.so", "/usr/local/lib/libfm.so", "/usr/local/lib/libdill.so", "/usr/local/lib/libcod.so"]
#Iterates over list, running statements for each item in the list
i = 0
while (i < 5):
if not os.path.exists(libs[i]):
call(cmds[i], shell=True)
i = i + 1
# obtain ocelot/hydrazine dependencies from svn
def ocelotDependencies():
print "[OCELOT DEPENDENCIES] begin ..."
svn_ocelot = 'svn export http://gpuocelot.googlecode.com/svn/trunk/ocelot/'
svn_hydrazine = 'svn export http://hydrazine.googlecode.com/svn/trunk/hydrazine'
if not os.path.exists("ocelot"):
for dir in ocelot_dir:
Execute(Mkdir(dir))
for file in ocelot_dep_headers:
cmd = svn_ocelot + file + ' ' + file;
call(cmd, shell=True)
for file in ocelot_dep:
cmd = svn_ocelot + file + ' ' + file;
call(cmd, shell=True)
for file in flex_sources:
cmd = svn_ocelot + file + ' ' + file;
call(cmd, shell=True)
for file in bison_sources:
cmd = svn_ocelot + file + ' ' + file;
call(cmd, shell=True)
if not os.path.exists("hydrazine"):
call(svn_hydrazine + ' hydrazine',
shell=True)
print "[OCELOT DEPENDENCIES] done."
# build C-JIT and ocelot dependencies
buildCJIT()
ocelotDependencies()
# Generate the flex/bison .c/.cpp files
for source in flex_sources:
lex = env.CXXFile(os.path.splitext(os.path.basename(str(source)))[0] \
+ '.cpp', str(source))
sources.append(lex[0])
for source in bison_sources:
bison = env.CXXFile(os.path.splitext(os.path.basename(str(source)))[0] \
+ '.cpp', str(source))
sources.append(bison[0])
bison_header = bison[1]
intermediate_headers.append(os.path.basename(str(bison_header)))
extensions = ['*.cpp']
for dir in directories:
for ext in extensions:
regexp = os.path.join(dir, ext)
sources.extend(env.Glob(regexp))
for file in ocelot_dep:
sources.append(file)
# Create the lynx library
lynx_dep_libs = env['EXTRA_LIBS']
if env['library'] == 'shared':
liblynxruntime = env.SharedLibrary('lynx_runtime', sources, LIBS=lynx_dep_libs)
else:
liblynxruntime = env.StaticLibrary('lynx_runtime', sources, LIBS=lynx_dep_libs)
# find all header files in the source tree
headers = []
directories = [ 'lynx/api/interface',
'lynx/cuda/interface',
'lynx/instrumentation/interface',
'lynx/transforms/interface',
'lynx/translator/interface',
'lynx/trace/interface',
'hydrazine/interface' ]
extensions = ['*.h', '*.hpp']
for dir in directories:
for ext in extensions:
regexp = os.path.join(dir, ext)
headers.extend(env.Glob(regexp))
for file in ocelot_dep_headers:
headers.extend(env.Glob(file))
lib_objs = []
lib_source_dir = [ 'lynx/api/implementation',
'lynx/instrumentation/implementation',
'lynx/transforms/implementation',
'lynx/translator/implementation',
'lynx/trace/implementation']
extensions = ['*.os']
for dir in lib_source_dir:
for ext in extensions:
regexp = os.path.join(dir, ext)
lib_objs.extend(env.Glob(regexp))
liblynx = env.SharedLibrary('lynx', lib_objs, LIBS=[lib for lib in lynx_dep_libs if lib != '-lcuda'])
if 'install' in COMMAND_LINE_TARGETS:
liblynxruntime = env.Install(os.path.join(env['install_path'], "lib"), liblynxruntime)
liblynx = env.Install(os.path.join(env['install_path'], "lib"), liblynx)
# Install rules
if 'install' in COMMAND_LINE_TARGETS:
print 'Installing lynx (library and runtime)...'
installed = []
installed.append(liblynxruntime)
installed.append(liblynx)
for header in headers:
(directoryPath, headerName) = os.path.split( \
os.path.relpath(str(header), prefix))
installed.append(env.Install(os.path.join( \
env['install_path'], "include", directoryPath), header))
for header in intermediate_headers:
(directoryPath, headerName) = os.path.split( \
os.path.relpath(str(header), '.'))
installed.append(env.Install(os.path.join( \
env['install_path'], "include", directoryPath), header))
for i in installed:
env.AddPostAction(str(i), Chmod(str(i), 0644))
env.Alias('install', env['install_path'])
env.Replace(installed_files = installed)
Export('env')