-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generator based template for reproducing issues.
- Loading branch information
1 parent
357e646
commit 43c055d
Showing
4 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Makefile inspired by the structure of the apps/ | ||
|
||
HALIDE_DISTRIB_PATH ?= ../../../distrib | ||
include ../../../apps/support/Makefile.inc | ||
|
||
.PHONY: build clean test codegen | ||
build: $(BIN)/$(HL_TARGET)/generated_pipeline.stmt | ||
|
||
|
||
$(GENERATOR_BIN)/generator: generator.cpp $(GENERATOR_DEPS) | ||
@mkdir -p $(@D) | ||
$(CXX) $(CXXFLAGS) $(filter %.cpp,$^) -o $@ $(LIBHALIDE_LDFLAGS) | ||
|
||
$(BIN)/%/generated_pipeline.stmt: $(GENERATOR_BIN)/generator | ||
@mkdir -p $(@D) | ||
$^ -g test_generator -e stmt,stmt_html,conceptual_stmt,conceptual_stmt_html,device_code,assembly,bitcode,static_library,c_header -o $(@D) -f generated_pipeline target=$* | ||
|
||
$(BIN)/%/test: $(BIN)/%/generated_pipeline.a test.cpp | ||
@mkdir -p $(@D) | ||
$(CXX) $(CXXFLAGS) -Wall -O2 -I$(BIN)/$* test.cpp $(BIN)/$*/generated_pipeline.a -o $@ $(LDFLAGS) | ||
|
||
test: $(BIN)/$(HL_TARGET)/test | ||
$< | ||
|
||
clean: | ||
rm -rf $(BIN) |
32 changes: 32 additions & 0 deletions
32
test/failing_with_issue/generator_based_template/README.md
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Generator template for making issues. | ||
|
||
## Making the generator and emitting the code. | ||
|
||
This folder contains an app-like structure, but is meant | ||
for making reproducible codegen issues. | ||
By default the generator will emit `stmt`, `stmt_html`, `conceptual_stmt`, | ||
`conceptual_stmt_html`, `device_code`, `assembly`, `bitcode`. | ||
|
||
To use this template, you ... | ||
1. Duplicate this folder and rename it (reference the issue number in the | ||
folder name if you have one). | ||
2. Edit the `generator.cpp` file to produce the issue you wish to | ||
demonstrate. | ||
3. Run `make HL_TARGET=...`, with your target triple (e.g., | ||
`HL_TARGET=host-cuda`). | ||
4. Open an issue and paste the generator code. | ||
|
||
As such, the everyone with the Halide repository checked out, can copy-paste | ||
your generator code and reproduce the issue with relative ease. | ||
|
||
## Running the code. | ||
|
||
If you additionally wish to run the code as part of the issue, there is a starter | ||
main-file provided `test.cpp`. There is an additional rule in the Makefile, which you can | ||
run with: | ||
|
||
```sh | ||
make HL_TARGET=... test | ||
``` | ||
|
||
If this is part of the problem demonstration, include this code in the issue. |
19 changes: 19 additions & 0 deletions
19
test/failing_with_issue/generator_based_template/generator.cpp
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include <Halide.h> | ||
using namespace Halide; | ||
|
||
class TestGenerator : public Generator<TestGenerator> { | ||
public: | ||
// Define Input/Outputs. | ||
Output<float> output{"output"}; | ||
|
||
void generate() { | ||
output() = 0.0f; | ||
// Fill in. | ||
} | ||
|
||
void schedule() { | ||
// Fill in. | ||
} | ||
}; | ||
|
||
HALIDE_REGISTER_GENERATOR(TestGenerator, test_generator) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "generated_pipeline.h" | ||
#include <HalideBuffer.h> | ||
#include <cstdio> | ||
|
||
int main(int argc, char **argv) { | ||
Halide::Runtime::Buffer<float, 0> output = Halide::Runtime::Buffer<float>::make_scalar(); | ||
generated_pipeline(output); | ||
std::printf("Output: %f\n", output()); | ||
|
||
return 0; | ||
} |