Skip to content

Commit

Permalink
Merge pull request #2 from kmowery/master
Browse files Browse the repository at this point in the history
Stop clang inlining; add a SETUP phase; allow variable names to be passe...
  • Loading branch information
dkohlbre committed Mar 25, 2015
2 parents ff6c79a + 71c7311 commit 33030d6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 12 additions & 5 deletions qtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,26 @@ class QTT:
temp_file = ""
testcount = 0
functions = {}
setup = ""
temp_file = "/tmp/qtt_tmp.c"

def gcc_build(self):
replace_file(HOST_C_FILE,self.temp_file,[
("INCLUDES_HERE",self.all_includes),
("FUNCTIONS_HERE", "\n".join(self.functions.values())),
("TESTFUNCTIONS",self.all_tests),
("SETUP", self.setup),
("TESTRUNS",self.all_testcalls)])

gccstring = "gcc -O -fforce-addr -std=c99 -o a.qtt -I. -L. "
gccstring = "gcc -O -std=c99 -o a.qtt -I. -L. "
for f in self.all_add_gcc_files:
if f != "":
if f[-2:] == '.c':
gccstring += "--include "+f+" "
elif f[-3:] == ".so":
gccstring += f+" "
elif f[:2] == "-l":
gccstring += f+" "
else:
print_unimp("File type:"+f)
return -1
Expand Down Expand Up @@ -102,12 +106,15 @@ def extract_c_data(self,cfunction,includefiles):

def arg_to_string(self,a):
if type(a) is str:
return '\"'+a+'\"'
return a
elif isinstance(a,QTTvar):
return a.s
else:
return str(a)

def add_setup(self, setup):
self.setup += setup + "\n"

def add_include(self,includefiles):
includes_s = ""
if includefiles != "":
Expand Down Expand Up @@ -153,7 +160,7 @@ def make_func(self, num, ret_s, types_s, typedargs_s, args_s):
# return (end-st-offset)/(float)PERF_ITRS;
# }

functext = "double __run_test_"+str(num)+"("+ret_s+" (*function) ("+types_s+"),"+typedargs_s+"){\n"
functext = "double __attribute__((noinline)) __run_test_"+str(num)+"("+ret_s+" (*function) ("+types_s+"),"+typedargs_s+"){\n"
functext +=" int ctr = 0;\n"
functext +=" uint8_t real = 0;\n"
functext +=" uint64_t st;\n"
Expand Down Expand Up @@ -270,9 +277,9 @@ def asm_snippet(self, fname, arglist, assembly, outputs, inputs, clobbers, testn

testruns = []
for args in arglist:
args = ", ".join([self.arg_to_string(a) for a in args])
args = ", ".join([self.arg_to_string(a) + "LL" for a in args])

testruns += [r"""printf("%s %-40s %%f\n", __run_test_%d(%s, %s));"""% \
testruns += [r"""printf("%s %-60s %%f\n", __run_test_%d(%s, %s));"""% \
(fname, args, testnum, test_function_name, args)]

return ("\n".join(testruns), self.make_func(testnum, function_type, types, typedargs, argnames))
Expand Down
2 changes: 2 additions & 0 deletions timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ int main(int argc, char* argv[]){
printf( "function "" cycles\n");
printf( "====================\n");

SETUP

TESTRUNS

return 0;
Expand Down

0 comments on commit 33030d6

Please sign in to comment.