Skip to content

Commit

Permalink
halide framework changes
Browse files Browse the repository at this point in the history
  • Loading branch information
alexnick83 committed Jun 24, 2022
1 parent 3e501c0 commit 1357c21
Showing 1 changed file with 27 additions and 18 deletions.
45 changes: 27 additions & 18 deletions npbench/infrastructure/halide_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def __init__(self, fname: str):

def version(self) -> str:
""" Returns the framework version. """
return pkg_resources.get_distribution("halide-python").version
# return pkg_resources.get_distribution("halide-python").version
return "1.0.0"

def implementations(self, bench: Benchmark) -> Sequence[Tuple[Callable, str]]:
""" Returns the framework's implementations for a particular benchmark.
Expand Down Expand Up @@ -74,26 +75,34 @@ def implementations(self, bench: Benchmark) -> Sequence[Tuple[Callable, str]]:
exec(generator_str)


try:
# try:


# Compile .so file
so_file_path = halide_cache / f"{module_name}_halide.so"
compiler = "g++"
flags = "-std=c++17 -O3 -pipe -fvisibility=hidden -fvisibility-inlines-hidden -fno-omit-frame-pointer -lz -rdynamic -Wl,-rpath,/usr/local/lib/ -fPIC"
includes = "-I/home/lukas/anaconda3/include/python3.9 -I/home/lukas/anaconda3/lib/python3.9/site-packages/pybind11/include -I/usr/local/include"
files = f"-shared {python_extension_path} {object_file_path} -o {so_file_path}"
so_compile_str = " ".join([compiler, flags, includes, files])
cmd = shlex.split(so_compile_str)
p = subprocess.Popen(cmd)
p.wait()
# Compile .so file
so_file_path = halide_cache / f"{module_name}_halide.so"
compiler = "g++"
flags = "-std=c++17 -O3 -pipe -fvisibility=hidden -fvisibility-inlines-hidden -fno-omit-frame-pointer -lz -rdynamic -Wl,-rpath,/usr/local/lib/ -fPIC"
# includes = "-I/home/lukas/anaconda3/include/python3.9 -I/home/lukas/anaconda3/lib/python3.9/site-packages/pybind11/include -I/usr/local/include"
includes = "-I /users/aziogas/anaconda3/include/python3.8"
files = f"-shared {python_extension_path} {object_file_path} -o {so_file_path}"
so_compile_str = " ".join([compiler, flags, includes, files])
cmd = shlex.split(so_compile_str)
p = subprocess.Popen(cmd)
p.wait()

print("Compiled")
print("Compiled")

except Exception as e:
print("Failed to load the Halide implementation.")
raise (e)
import importlib.util
spec = importlib.util.spec_from_file_location(
bench.info["module_name"] + "_halide", so_file_path)
foo = importlib.util.module_from_spec(spec)
spec.loader.exec_module(foo)
impl = eval("foo.{f}".format(f=bench.info["func_name"] + "_halide"))

impl = None
# except Exception as e:
# print("Failed to load the Halide implementation.")
# raise (e)

return [(None, "default")]
# impl = ct_impl

return [(impl, "default")]

0 comments on commit 1357c21

Please sign in to comment.