if minimal: llvm_cfg = llvm_cfg + ['--enable-targets=host,ptx,x86_64,arm'] else: llvm_cfg = llvm_cfg + [ '--enable-targets=all', '--enable-docs', '--enable-doxygen' ] status('''Configuring llvm: %s''' % llvm_cfg) print configure(llvm_cfg) status('Building llvm') # print make('-j', '--load-average=%f' % max_load) print make('-j12') chdir('docs') if not minimal: make('ocamldoc', '-j', '--load-average=%f' % max_load) # optional: check_call('make doxygen'.split(' ')) chdir('../..') assert check_llvm() # Test building chdir('src') status('Test: building halide.cmxa') print ocamlbuild('-use-ocamlfind', 'halide.cmxa') chdir('..') status('Building C++ bindings') print make('-C', 'cpp_bindings', '-j1') # can be flakey with first parallel build on SSD
def test(name): if name.startswith('cpp/'): return test_cpp(name) # status(name, 'Building bitcode') # Set up filenames cfgfile = "%s.json" % name bcfile = "%s.bc" % name asmfile = "%s.s" % name sofile = "%s.so" % name outfile = "%s.png" % name tmpfile = "%s.tmp" % name logfile = "%s.log" % name errfile = "%s.err" % name timefile = "%s.time" % name # Build the ocaml test target = '%s/%s.byte' % (name, name) cmd = "-no-links %s" % target ocamlbuild(cmd.split(' ')) # Dive in os.chdir(name) # Clean up old cruft remove(bcfile) remove(asmfile) remove(sofile) remove(outfile) remove(logfile) remove(errfile) remove(timefile) # Codegen the bitcode runner = Command("../_build/%s" % target) runner() # Compile the plugin # status(name, 'Building plugin') # Codegen the bitcode llc("-O3", "-disable-cfi", bcfile) # Load plugin info from generated json opts = json.load(open(cfgfile)) # TODO: move helpstr, num_popped into externs imported straight from the LLVM module? assert opts['name'] == name opts['classname'] = 'Test'+name.title() opts['namestr'] = 'test_'+name # Compile the thing cmd = [ "-O3", "-Xlinker", "-dylib", "-Xlinker", "-undefined", "-Xlinker", "dynamic_lookup", "-DCLASSNAME=%(classname)s" % opts, "-DNUM_POPPED=%(num_popped)d" % opts, "-DHELPSTR=\"%(helpstr)s\"" % opts, "-DNAMESTR=\"%(namestr)s\"" % opts, "../test_plugin.cpp", asmfile, "-I../../ImageStack/src", "-o", sofile ] cxx(cmd) # Run the plugin # status(name, 'Running plugin') cmd = [ '-plugin', sofile, ] cmd = cmd + opts['before_run'] + ['-test_%s' % name] + opts['args'] + ['-save', outfile] + ['-save', tmpfile] cmd = cmd + opts['validation'] out = imagestack(cmd, _out=logfile, _err=errfile) # Expect result as float in last line of output try: residual = float(out.splitlines()[-1]) assert(residual < EPSILON) sys.stdout.write(".") sys.stdout.flush() except: print "%s failed!" % name if verbose: print "Output:\n%s" % out # Expect runtime as float (seconds) in some line like "_im_time: %f" time = 0.0 try: timestr = "_im_time: " times = [l.split(timestr)[-1] for l in out.splitlines() if l.startswith(timestr)] time = [float(t) for t in times][0] with open(timefile, "w") as f: f.write("%f" % time) except: print "Failed to get time!" # Pop out os.chdir("..")
if minimal: llvm_cfg = llvm_cfg + ["--enable-targets=host,ptx,x86_64,arm"] else: llvm_cfg = llvm_cfg + ["--enable-targets=all", "--enable-docs", "--enable-doxygen"] status( """Configuring llvm: %s""" % llvm_cfg ) print configure(llvm_cfg) status("Building llvm") # print make('-j', '--load-average=%f' % max_load) print make("-j12") chdir("docs") if not minimal: make("ocamldoc", "-j", "--load-average=%f" % max_load) # optional: check_call('make doxygen'.split(' ')) chdir("../..") assert check_llvm() # Test building chdir("src") status("Test: building halide.cmxa") print ocamlbuild("-use-ocamlfind", "halide.cmxa") chdir("..") status("Building C++ bindings") print make("-C", "cpp_bindings", "-j1") # can be flakey with first parallel build on SSD