Debian Codegraph @

apps/fft/Makefile

raw
1 include ../support/Makefile.inc
2
3 CXXFLAGS += -g -Wall
4
5 .PHONY: build clean test
6
7 ifeq ($(WITH_FFTW),1)
8 CXXFLAGS += -DWITH_FFTW
9 LDFLAGS += -lfftw3f
10 endif
11
12 # Use a small stack, to stress out the compiler and act as a canary
13 # for stack bloat problems. This can be accomplished with a linker
14 # flag on os x, and testing this on one platform is sufficient.
15 UNAME = $(shell uname)
16 ifeq ($(UNAME), Darwin)
17 LDFLAGS += -Wl,-stack_size -Wl,0x100000
18 endif
19
20 build: $(BIN)/$(HL_TARGET)/bench_fft
21
22 $(BIN)/%/bench_fft: main.cpp fft.cpp fft.h complex.h funct.h $(LIB_HALIDE)
23 @mkdir -p $(@D)
24 $(CXX) $(CXXFLAGS) $(filter-out %.h,$^) -o $@ $(LIBHALIDE_LDFLAGS)
25
26 bench_8x8: $(BIN)/$(HL_TARGET)/bench_fft
27 $< 8 8 $(<D)
28
29 bench_12x12: $(BIN)/$(HL_TARGET)/bench_fft
30 $< 12 12 $(<D)
31
32 bench_16x16: $(BIN)/$(HL_TARGET)/bench_fft
33 $< 16 16 $(<D)
34
35 bench_24x24: $(BIN)/$(HL_TARGET)/bench_fft
36 $< 24 24 $(<D)
37
38 bench_32x32: $(BIN)/$(HL_TARGET)/bench_fft
39 $< 32 32 $(<D)
40
41 bench_48x48: $(BIN)/$(HL_TARGET)/bench_fft
42 $< 48 48 $(<D)
43
44 bench_64x64: $(BIN)/$(HL_TARGET)/bench_fft
45 $< 64 64 $(<D)
46
47 $(GENERATOR_BIN)/fft.generator: fft_generator.cpp fft.cpp fft.h $(GENERATOR_DEPS)
48 @mkdir -p $(@D)
49 $(CXX) $(CXXFLAGS) $(filter %.cpp,$^) -o $@ $(LIBHALIDE_LDFLAGS)
50
51 # Generate four AOT compiled FFT variants. Forward versions have gain set to 1 / 256.0
52 $(BIN)/%/fft_forward_r2c.a: $(GENERATOR_BIN)/fft.generator
53 @mkdir -p $(@D)
54 $^ -g fft -e $(GENERATOR_OUTPUTS) -o $(@D) -f fft_forward_r2c target=$* direction=samples_to_frequency size0=16 size1=16 gain=0.00390625 input_number_type=real output_number_type=complex
55
56 $(BIN)/%/fft_inverse_c2r.a: $(GENERATOR_BIN)/fft.generator
57 @mkdir -p $(@D)
58 $^ -g fft -e $(GENERATOR_OUTPUTS) -o $(@D) -f fft_inverse_c2r target=$* direction=frequency_to_samples size0=16 size1=16 input_number_type=complex output_number_type=real
59
60 $(BIN)/%/fft_forward_c2c.a: $(GENERATOR_BIN)/fft.generator
61 @mkdir -p $(@D)
62 $^ -g fft -e $(GENERATOR_OUTPUTS) -o $(@D) -f fft_forward_c2c target=$* direction=samples_to_frequency size0=16 size1=16 gain=0.00390625 input_number_type=complex output_number_type=complex
63
64 $(BIN)/%/fft_inverse_c2c.a: $(GENERATOR_BIN)/fft.generator
65 @mkdir -p $(@D)
66 $^ -g fft -e $(GENERATOR_OUTPUTS) -o $(@D) -f fft_inverse_c2c target=$* direction=frequency_to_samples size0=16 size1=16 input_number_type=complex output_number_type=complex
67
68 $(BIN)/%/fft_aot_test: fft_aot_test.cpp $(BIN)/%/fft_forward_r2c.a $(BIN)/%/fft_inverse_c2r.a $(BIN)/%/fft_forward_c2c.a $(BIN)/%/fft_inverse_c2c.a
69 @mkdir -p $(@D)
70 $(CXX) -I$(BIN)/$* -I$(HALIDE_DISTRIB_PATH)/include/ -std=c++17 $^ -o $@ $(LDFLAGS)
71
72 clean:
73 rm -rf $(BIN)
74
75 fft_aot_test: $(BIN)/$(HL_TARGET)/fft_aot_test
76 $^
77
78 all: fft_aot_test bench_16x16 bench_32x32 bench_48x48 bench_64x64
79
80 # Ensure these are run sequentially and not in parallel
81 test: $(BIN)/$(HL_TARGET)/bench_fft
82 $< 8 8 $(<D)
83 $< 12 12 $(<D)
84 $< 16 16 $(<D)
85 $< 24 24 $(<D)
86 $< 32 32 $(<D)
87 $< 48 48 $(<D)