Skip to content

Commit fb4faca

Browse files
committed
import into Eclipse
Create OpenCL module (initially copy of CUDA module). Change occurrences of cuda to opencl add OpenCL option to orio_main add orcl script to launch orio with OpenCL support Setup script copies orcl set default build command Create OpenCL module (initially copy of CUDA module). Change occurrences of cuda to opencl generate CUDA code without tinfo import into Eclipse import into Eclipse Create OpenCL module (initially copy of CUDA module). Change occurrences of cuda to opencl add OpenCL option to orio_main add orcl script to launch orio with OpenCL support Setup script copies orcl set default build command Create OpenCL module (initially copy of CUDA module). Change occurrences of cuda to opencl generate CUDA code without tinfo import into Eclipse Create OpenCL module (initially copy of CUDA module). import into Eclipse Create OpenCL module (initially copy of CUDA module). Change occurrences of cuda to opencl add OpenCL option to orio_main add orcl script to launch orio with OpenCL support Setup script copies orcl set default build command Create OpenCL module (initially copy of CUDA module). Change occurrences of cuda to opencl generate CUDA code without tinfo import into Eclipse Create OpenCL module (initially copy of CUDA module). Change occurrences of cuda to opencl add OpenCL option to orio_main add orcl script to launch orio with OpenCL support Setup script copies orcl import into Eclipse Create OpenCL module (initially copy of CUDA module). Change occurrences of cuda to opencl add OpenCL option to orio_main add orcl script to launch orio with OpenCL support Setup script copies orcl set default build command Create OpenCL module (initially copy of CUDA module). Change occurrences of cuda to opencl generate CUDA code without tinfo import into Eclipse Create OpenCL module (initially copy of CUDA module). Change occurrences of cuda to opencl add OpenCL option to orio_main add orcl script to launch orio with OpenCL support Setup script copies orcl set default build command import into Eclipse Create OpenCL module (initially copy of CUDA module). Change occurrences of cuda to opencl add OpenCL option to orio_main add orcl script to launch orio with OpenCL support Setup script copies orcl set default build command Create OpenCL module (initially copy of CUDA module). Change occurrences of cuda to opencl generate CUDA code without tinfo import into Eclipse Create OpenCL module (initially copy of CUDA module). Change occurrences of cuda to opencl add OpenCL option to orio_main add orcl script to launch orio with OpenCL support Setup script copies orcl set default build command generate CUDA code without tinfo import into Eclipse Change occurrences of cuda to opencl add OpenCL option to orio_main add orcl script to launch orio with OpenCL support import into Eclipse Create OpenCL module (initially copy of CUDA module). Change occurrences of cuda to opencl add OpenCL option to orio_main add orcl script to launch orio with OpenCL support Setup script copies orcl set default build command Create OpenCL module (initially copy of CUDA module). Change occurrences of cuda to opencl generate CUDA code without tinfo import into Eclipse Create OpenCL module (initially copy of CUDA module). Change occurrences of cuda to opencl add OpenCL option to orio_main add orcl script to launch orio with OpenCL support Setup script copies orcl set default build command generate CUDA code without tinfo import into Eclipse Change occurrences of cuda to opencl add OpenCL option to orio_main add orcl script to launch orio with OpenCL support set default build command Setup script copies orcl OpenCL properties query need to read properties before tranformation arguments --amend redirect props to file process props from multiple platforms and devices process props from multiple platforms and devices import into Eclipse Create OpenCL module (initially copy of CUDA module). Change occurrences of cuda to opencl add OpenCL option to orio_main add orcl script to launch orio with OpenCL support Setup script copies orcl set default build command Create OpenCL module (initially copy of CUDA module). Change occurrences of cuda to opencl generate CUDA code without tinfo import into Eclipse Create OpenCL module (initially copy of CUDA module). Change occurrences of cuda to opencl add OpenCL option to orio_main add orcl script to launch orio with OpenCL support Setup script copies orcl set default build command generate CUDA code without tinfo import into Eclipse Change occurrences of cuda to opencl add OpenCL option to orio_main add orcl script to launch orio with OpenCL support set default build command Setup script copies orcl OpenCL properties query need to read properties before tranformation arguments --amend redirect props to file process props from multiple platforms and devices process props from multiple platforms and devices process props from multiple platforms and devices handle platform properties remove domain code from opencl transformation import into Eclipse Create OpenCL module (initially copy of CUDA module). Change occurrences of cuda to opencl add OpenCL option to orio_main add orcl script to launch orio with OpenCL support Setup script copies orcl set default build command Create OpenCL module (initially copy of CUDA module). Change occurrences of cuda to opencl generate CUDA code without tinfo import into Eclipse Create OpenCL module (initially copy of CUDA module). Change occurrences of cuda to opencl add OpenCL option to orio_main add orcl script to launch orio with OpenCL support Setup script copies orcl set default build command generate CUDA code without tinfo import into Eclipse Change occurrences of cuda to opencl add OpenCL option to orio_main add orcl script to launch orio with OpenCL support set default build command Setup script copies orcl OpenCL properties query need to read properties before tranformation arguments --amend redirect props to file process props from multiple platforms and devices process props from multiple platforms and devices process props from multiple platforms and devices handle platform properties remove domain code from opencl transformation remove domain code from opencl transformation remove L1 cache setting, which is not available in OpenCL remove L1 cache setting, which is not available in OpenCL opencl boilerplate and kernel generation opencl support in ptest_driver add runtime error checking for OpenCL\ opencl works for matScale some fixes to reductions fix types in reduction kernels add tests skeleton file for performance measurement with TAU use build command to build query code pass tinfo to opencl submodule only use local memory barrier, not global add post-command option (for taudb_loadtrial) metadata vecHint, sizeHint options Save OpenCL attributes as TAU metadata generate unique filenames for profiles allow filename twice in post-command OpenCL compile flag arguments were in wrong position put missing .iteritems() back (I don't know how it got deleted!) fix transformation argument parsing for platform and device Insert timer calls (need to fix this to only do this when using TAU) Move end of execute timer to after blocking copy. Add vecAXPY example. Update tau_skeleton.c to use timers around OpenCL executions when OpenCL is used. vecMAXPY WAXPY ex14FF Don't output TAU_METADATA except for OpenCL. Spell 'language' correctly. ex14FJ viennacl
1 parent e623c13 commit fb4faca

32 files changed

+2848
-26
lines changed

.pydevproject

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<?eclipse-pydev version="1.0"?>
3-
4-
<pydev_project>
5-
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
6-
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.6</pydev_property>
2+
<?eclipse-pydev version="1.0"?><pydev_project>
3+
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">python27</pydev_property>
4+
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
75
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
8-
<path>/orio</path>
6+
<path>/Orio-svn</path>
97
</pydev_pathproperty>
108
</pydev_project>

orcl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env python
2+
#
3+
# orf - Compile shell for Orio (generate OpenCL source code)
4+
#
5+
6+
import os, sys, distutils.sysconfig
7+
8+
# include the annotation tool in the Python's search path
9+
abs_path = os.path.realpath(sys.argv[0])
10+
cur_dir = os.path.dirname(abs_path)
11+
dirs=[]
12+
if os.path.basename(cur_dir) == 'bin':
13+
# installed location
14+
base_dir = os.path.join(os.path.dirname(cur_dir),'lib','python' + distutils.sysconfig.get_python_version(),'site-packages')
15+
dirs = [base_dir, os.path.join(base_dir,'orio')]
16+
else:
17+
# source tree (development) location
18+
dirs = [os.path.join(cur_dir,'orio')]
19+
sys.path.extend(dirs)
20+
21+
22+
# dispatch to Orio's main
23+
import orio.main.orio_main
24+
orio.main.orio_main.start(sys.argv, orio.main.orio_main.OPENCL)
25+

orio/main/cmd_line_opts.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
1717
Options:
1818
-c, --pre-command=<string> Command string with which to prefix the execution of the
19-
Orio-built code, e.g., tauex
19+
Orio-built code, e.g., tau_exec
20+
--post-command=<string> Command string to run after each execution of Orio-built code,
21+
e.g., taudb_loadtrial
2022
-e, --erase-annot remove annotations from the output
2123
-h, --help display this message
2224
-o <file>, --output=<file> place the output in <file> (only valid when processing
@@ -121,7 +123,7 @@ def parse(self, argv):
121123
opts, args = getopt.getopt(orioargv,
122124
'c:ehko:p:rs:vx',
123125
['pre-command=', 'config=','configfile=', 'erase-annot', 'help', 'keep-temps',' output=',
124-
'output-prefix=', 'rename-objects', 'spec=', 'verbose', 'extern', 'validate'])
126+
'output-prefix=', 'rename-objects', 'spec=', 'verbose', 'extern', 'validate', 'post-command='])
125127
except Exception, e:
126128
sys.stderr.write('Orio command-line error: %s' % e)
127129
sys.stderr.write(USAGE_MSG + '\n')
@@ -131,6 +133,8 @@ def parse(self, argv):
131133
for opt, arg in opts:
132134
if opt in ('-c', '--pre-command'):
133135
cmdline['pre_cmd'] = arg
136+
elif opt in ('--post-command'):
137+
cmdline['post_cmd'] = arg
134138
elif opt in ('-e', '--erase-annot'):
135139
cmdline['erase_annot'] = True
136140
elif opt in ('-h', '--help'):

orio/main/opt_driver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def __optimizeCodeFrag(self, cfrag, perf_params):
134134

135135
# apply code transformations
136136
try:
137-
if self.lang == 'cuda':
137+
if self.lang == 'cuda' or self.lang == 'opencl':
138138
transformation = mod_class(perf_params,
139139
cfrag.leader_ann.mod_code,
140140
optimized_body_code,

orio/main/orio_main.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
C_CPP = 1
1212
FORTRAN = 2
1313
CUDA = 3
14+
OPENCL = 4
1415

1516
#----------------------------------------------
1617

@@ -26,6 +27,8 @@ def start(argv, lang):
2627
language = 'c'
2728
elif lang == CUDA:
2829
language = 'cuda'
30+
elif lang == OPENCL:
31+
language = 'opencl'
2932
else:
3033
sys.stderr.write('orio.main.main: Language not supported at this time.')
3134
sys.exit(1)

orio/main/tspec/pparser.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
'simplex_reflection_coef', 'simplex_expansion_coef',
2222
'simplex_contraction_coef', 'simplex_shrinkage_coef', 'simplex_local_distance', 'simplex_x0',
2323
'validation', 'validation_file', 'expected_output'
24-
, 'macro'
24+
, 'macro', 'performance_test_code', 'skeleton_test_code', 'skeleton_code_file'
2525
]
2626

2727
# map of reserved keywords
@@ -139,6 +139,7 @@ def p_def_type(p):
139139
| INPUT_VARS
140140
| SEARCH
141141
| VALIDATION
142+
| PERFORMANCE_TEST_CODE
142143
'''
143144
p[0] = (p[1], p.lineno(1))
144145

@@ -207,6 +208,8 @@ def p_arg_type(p):
207208
| SIMPLEX_X0
208209
| VALIDATION_FILE
209210
| EXPECTED_OUTPUT
211+
| SKELETON_TEST_CODE
212+
| SKELETON_CODE_FILE
210213
'''
211214
p[0] = (p[1], p.lineno(1))
212215

orio/main/tuner/ptest_codegen.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44

55
import random, re
6-
import skeleton_code
6+
import skeleton_code
77
from orio.main.util.globals import *
88
from orio.main.tuner.skeleton_code import SEQ_TIMER
99

@@ -345,7 +345,11 @@ def generate(self, code_map):
345345
if not self.decl_file:
346346
prologue_code += ('%s();' % self.malloc_func_name) + '\n '
347347
prologue_code += ('%s();' % self.init_func_name) + '\n'
348-
348+
349+
if Globals().language == 'opencl':
350+
for (k, v) in Globals().metadata.iteritems():
351+
prologue_code += 'TAU_METADATA("%s", "%s");\n' % (k, v)
352+
349353
# create code for the epilogue section
350354
epilogue_code = ''
351355
#if not self.decl_file:
@@ -372,6 +376,15 @@ def __init__(self, input_params, input_decls, decl_file, init_file, skeleton_cod
372376
super(PerfTestCodeGenCUDA, self).__init__(input_params, input_decls, decl_file, init_file, skeleton_code_file, language,
373377
random_seed, use_parallel_search)
374378

379+
# --------------------------------------------------------------------------------------
380+
class PerfTestCodeGenOpenCL(PerfTestCodeGen):
381+
382+
def __init__(self, input_params, input_decls, decl_file, init_file, skeleton_code_file, language='opencl',
383+
random_seed=None, use_parallel_search=False):
384+
super(PerfTestCodeGenOpenCL, self).__init__(input_params, input_decls, decl_file, init_file, skeleton_code_file, language,
385+
random_seed, use_parallel_search)
386+
387+
375388

376389
# --------------------------------------------------------------------------------------
377390

orio/main/tuner/ptest_driver.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
# To compile and execute the performance-testing code to get the performance cost
33
#
44

5-
import os, time, re
5+
import os, time, re, datetime, uuid
66

77
from orio.main.util.globals import *
88

9+
910
#-----------------------------------------------------
1011

1112
perftest_counter = 0
@@ -37,13 +38,13 @@ def __init__(self, tinfo, use_parallel_search, language="c", timing_code=''):
3738
global perftest_counter
3839
perftest_counter += 1
3940

40-
if not (language == 'c' or language == 'fortran' or language == 'cuda'):
41+
if not (language == 'c' or language == 'fortran' or language == 'cuda' or language == 'opencl'):
4142
err('orio.main.tuner.ptest_driver: unknown output language specified: %s' % language)
4243
self.language = language
4344

4445
self.__PTEST_FNAME=Globals().out_prefix+self.__PTEST_FNAME
4546

46-
if language == 'c':
47+
if language == 'c' or language == 'opencl':
4748
self.ext = '.c'
4849
elif language == 'cuda':
4950
self.ext = '.cu'
@@ -55,7 +56,7 @@ def __init__(self, tinfo, use_parallel_search, language="c", timing_code=''):
5556
self.original_src_name = self.__PTEST_FNAME + '_original' + self.ext
5657
self.exe_name = self.__PTEST_FNAME + '.exe'
5758
self.original_exe_name = self.__PTEST_FNAME + '_original.exe'
58-
if self.language == 'cuda':
59+
if self.language == 'cuda' or self.language == 'opencl':
5960
self.obj_name = self.__PTEST_FNAME + '.o'
6061
self.original_obj_name = self.__PTEST_FNAME + '_original.o'
6162

@@ -106,7 +107,7 @@ def __write(self, test_code, perf_param=None):
106107
err('orio.main.tuner.ptest_driver: cannot open file for writing: %s' % self.src_name)
107108

108109
if self.first:
109-
if self.language != 'cuda' and not self.tinfo.timer_file and not (os.path.exists(self.timer_file)):
110+
if self.language != 'cuda' and self.language != 'opencl' and not self.tinfo.timer_file and not (os.path.exists(self.timer_file)):
110111
# Generate the timing routine file
111112
try:
112113
f = open(self.timer_file, 'w')
@@ -214,6 +215,10 @@ def __build(self, perf_param=None):
214215
if status:
215216
err('orio.main.tuner.ptest_driver: failed to compile the test cuda code: "%s"' % cmd)
216217
cmd = ('%s %s -o %s %s' % (build_cmd, self.extra_compiler_opts, self.exe_name, self.obj_name))
218+
elif self.language == 'opencl':
219+
cmd = ('%s %s -o %s %s %s' % (build_cmd, self.extra_compiler_opts,
220+
self.exe_name, self.src_name2,
221+
self.tinfo.libs))
217222
else:
218223
cmd = ('%s %s -o %s %s %s %s' % (build_cmd, self.extra_compiler_opts,
219224
self.exe_name, self.src_name2,
@@ -245,6 +250,8 @@ def __build(self, perf_param=None):
245250
def __execute(self):
246251
'''Execute the test to get the performance costs'''
247252

253+
Globals().metadata['src_filenames'] = ",".join(Globals().src_filenames)
254+
248255
# check if the executable exists
249256
if not os.path.exists(self.exe_name):
250257
err('orio.main.tuner.ptest_driver: the executable of the test code does not exist')
@@ -295,6 +302,19 @@ def __execute(self):
295302
except Exception, e:
296303
err('orio.main.tuner.ptest_driver: failed to execute the test code: "%s"\n --> %s: %s' % (cmd,e.__class__.__name__, e))
297304

305+
if Globals().post_cmd is not None:
306+
try:
307+
cmd = Globals().post_cmd
308+
uniq = "profile-" + datetime.datetime.now().strftime("%y-%m-%d:%H:%S") + '-' + uuid.uuid4().hex
309+
if "%s" in cmd:
310+
cmd = cmd % (uniq, uniq)
311+
status = os.system(cmd)
312+
if status:
313+
err('orio.main.tuner.ptest_driver: failed to execute the post-command: "%s"' % Globals().post_cmd)
314+
except Exception, e:
315+
err('orio.main.tuner.ptest_driver: failed to execute the post-command: "%s"\n --> %s: %s' % (Globals().post_cmd,e.__class__.__name__, e))
316+
317+
298318
try:
299319
if out:
300320
#info('out: %s' % out)
@@ -374,7 +394,6 @@ def run(self, test_code, perf_param=None):
374394
@param test_code: the code for testing multiple coordinates in the search space
375395
@return: a dictionary of the times corresponding to each coordinate in the search space
376396
'''
377-
378397
# write the testing code
379398
self.__write(test_code, perf_param=perf_param)
380399

orio/main/tuner/skeleton_code.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -449,10 +449,10 @@ def __init__(self, code, use_parallel_search, language='c'):
449449
if use_parallel_search:
450450
code = PAR_DEFAULT
451451
else:
452-
if language == 'c':
453-
code = SEQ_DEFAULT
454-
else:
452+
if language == 'cuda':
455453
code = SEQ_DEFAULT_CUDA
454+
else:
455+
code = SEQ_DEFAULT
456456

457457
self.code = code
458458
self.use_parallel_search = use_parallel_search

orio/main/tuner/tuner.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,12 @@ def tune(self, module_body_code, line_no, cfrags):
6666
c = orio.main.tuner.ptest_codegen.PerfTestCodeGenCUDA(prob_size, tinfo.ivar_decls, tinfo.ivar_decl_file,
6767
tinfo.ivar_init_file, tinfo.ptest_skeleton_code_file, self.odriver.lang,
6868
tinfo.random_seed, use_parallel_search)
69-
69+
70+
elif self.odriver.lang == 'opencl':
71+
c = orio.main.tuner.ptest_codegen.PerfTestCodeGenCUDA(prob_size, tinfo.ivar_decls, tinfo.ivar_decl_file,
72+
tinfo.ivar_init_file, tinfo.ptest_skeleton_code_file, self.odriver.lang,
73+
tinfo.random_seed, use_parallel_search)
74+
7075
elif self.odriver.lang == 'fortran':
7176
c = orio.main.tuner.ptest_codegen.PerfTestCodeGenFortran(prob_size, tinfo.ivar_decls, tinfo.ivar_decl_file,
7277
tinfo.ivar_init_file, tinfo.ptest_skeleton_code_file, self.odriver.lang,
@@ -124,6 +129,11 @@ def tune(self, module_body_code, line_no, cfrags):
124129
iparams.sort(lambda x,y: cmp(x[0],y[0]))
125130
for pname, pvalue in iparams:
126131
info(' %s = %s' % (pname, pvalue))
132+
133+
iparams = ptcodegen.input_params[:]
134+
iparams.sort(lambda x,y: cmp(x[0],y[0]))
135+
for pname, pvalue in iparams:
136+
Globals().metadata['size_' + pname] = pvalue
127137

128138
# create the search engine
129139
search_eng = search_class({'cfrags':cfrags,

0 commit comments

Comments
 (0)