Last active
June 6, 2016 18:32
-
-
Save ronen/28d109efe74006e9d4dd576655f445db to your computer and use it in GitHub Desktop.
Demo of halide Metal AOT backend initialization/termination bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Halide.h" | |
class Dummy: public Halide::Generator<Dummy> | |
{ | |
public: | |
Halide::ImageParam input{Halide::UInt(8), 3, "input"}; | |
Halide::Var x, y, c; | |
Halide::Func build() | |
{ | |
Halide::Func filter; | |
filter(x, y, c) = input(x, y, c); | |
return filter; | |
} | |
}; | |
Halide::RegisterGenerator<Dummy> dummy{"dummy"}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main() | |
{ | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CXXFLAGS = -std=c++11 -g | |
HALIDE_TOOLS_DIR = /usr/local/share/halide/tools | |
default: demo | |
.PHONY: clean | |
demo: build/main.o build/halide_dummy_metal.o | |
$(CXX) $(CXXFLAGS) -o $@ $^ -framework Cocoa -framework Metal | |
clean: | |
rm -rf build | |
build/halide_%_metal.o: halide_%.cpp | |
build/%_metal.o build/%_metal.h: build/generate_% | |
$^ -e o -o build -f $(basename $(notdir $@)) target=metal | |
build/generate_halide_%: halide_%.cpp $(HALIDE_TOOLS_DIR)/GenGen.cpp | |
@mkdir -p $(dir $@) | |
$(CXX) $(CXXFLAGS) -fno-rtti $^ -o $@ -lHalide | |
build/%.o: %.cpp | |
@mkdir -p $(dir $@) | |
$(CXX) -c $(CXXFLAGS) -o $@ $< |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Stripped down this to a trivial test case: A
main()
that doesn't even call the halide function, but gets an assertion errorThe files are available in https://gist.github.com/ronen/28d109efe74006e9d4dd576655f445db. In particular, notice that main.cpp is just:
And you'll see the filter generator is also trivial. Generating the filter with
-e o target=metal
and linking the .o's leads to a program that gets an assertion failure upon exit. To reproduce, grab the files from the gist, then: