-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
133 lines (108 loc) · 3.35 KB
/
Makefile
File metadata and controls
133 lines (108 loc) · 3.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
CC ?= cc
AR ?= ar
RANLIB ?= ranlib
CFLAGS ?= -std=c99 -Wall -Wextra -O2 -Iinclude
LDFLAGS ?=
LIB := libloxc.a
SRC_OBJS := \
src/loxc.o \
src/loxc_base.o \
src/loxc_plain.o \
src/loxc_matrix.o \
src/loxc_dict.o \
src/loxc_stream.o \
src/loxc_strategy.o \
src/loxc_hier.o \
src/loxc_loader.o \
src/loxc_simple.o
TOOLS := \
tools/loxc_train \
tools/loxc_cli \
tools/loxc_bench
EXAMPLES := \
examples/01_hello_world \
examples/02_compress_file \
examples/03_embedded_mode \
examples/04_error_handling \
examples/05_training_pipeline \
examples/06_compare_modes \
examples/07_streaming_chunks
TESTS := \
tests/test_basic \
tests/test_matrix \
tests/test_dict \
tests/test_stream \
tests/test_header \
tests/test_plain \
tests/test_strategy \
tests/test_hier \
tests/test_registry \
tests/test_simple \
tests/test_loader \
tests/test_train_demo
.PHONY: all test bench examples clean
all: $(LIB) $(TOOLS) $(TESTS)
$(LIB): $(SRC_OBJS)
$(AR) rcs $@ $^
-$(RANLIB) $@
src/%.o: src/%.c
$(CC) $(CFLAGS) -c -o $@ $<
tools/%: tools/%.c $(LIB)
$(CC) $(CFLAGS) -o $@ $< $(LIB) $(LDFLAGS)
tools/loxc_bench: tools/loxc_bench.c $(LIB) modules/loxc_demo.o
$(CC) $(CFLAGS) -Imodules -DLOXC_BENCH_WITH_DEMO -o $@ $< modules/loxc_demo.o $(LIB) $(LDFLAGS)
tests/%: tests/%.c $(LIB)
$(CC) $(CFLAGS) -o $@ $< $(LIB) $(LDFLAGS)
examples/%: examples/%.c $(LIB) modules/loxc_demo.loxctab
$(CC) $(CFLAGS) -Iinclude -Imodules -o $@ $< $(LIB) $(LDFLAGS)
modules/loxc_demo.c modules/loxc_demo.h modules/loxc_demo.loxctab: tools/loxc_train trainings/demo_corpus.txt
./tools/loxc_train --input trainings/demo_corpus.txt --output modules/loxc_demo --module-name demo --module-id 10
modules/loxc_demo.o: modules/loxc_demo.c src/loxc_stream.o src/loxc_base.o
$(CC) $(CFLAGS) -Imodules -c -o $@ modules/loxc_demo.c
tests/test_train_demo: tests/test_train_demo.c $(LIB) modules/loxc_demo.o
$(CC) $(CFLAGS) -Imodules -o $@ $< modules/loxc_demo.o $(LIB) $(LDFLAGS)
test: $(TESTS)
@tests/test_basic
@tests/test_matrix
@tests/test_dict
@tests/test_stream
@tests/test_header
@tests/test_plain
@tests/test_strategy
@tests/test_hier
@tests/test_registry
@tests/test_simple
@tests/test_loader
@tests/test_train_demo
bench: tools/loxc_bench
@tools/loxc_bench
tools/loxc_bench2: tools/loxc_bench2.c $(LIB)
$(CC) $(CFLAGS) -o $@ $< $(LIB) $(LDFLAGS) -lm
.PHONY: bench2 bench-full bench-clean
bench2: tools/loxc_bench2 modules/loxc_demo.loxctab
@mkdir -p bench_out
@if [ ! -s benchmarks/suite.list ]; then \
printf '%s\n' \
'trainings/demo_corpus.txt' \
'benchmarks/plain_sample_text.txt' \
'benchmarks/tiny.txt' 'benchmarks/small.txt' \
'benchmarks/medium.txt' 'benchmarks/source.c' \
'benchmarks/data.json' \
> benchmarks/suite.list; \
fi
./tools/loxc_bench2 \
--table modules/loxc_demo.loxctab \
--suite benchmarks/suite.list \
--iterations $(ITER) --warmup 3 \
--csv bench_out/loxc_demo.csv \
--json bench_out/loxc_demo.json
bench-full: tools/loxc_bench2 tools/loxc_train
./tools/bench_run.sh $(ITER)
bench-clean:
rm -rf bench_out
rm -f benchmarks/suite.list benchmarks/plain_sample_text.txt
rm -rf benchmarks/corpora trainings/extra
rm -f modules/loxc_json.* modules/loxc_logs.* modules/loxc_csrc.*
examples: $(EXAMPLES)
clean:
$(RM) $(SRC_OBJS) $(LIB) $(TOOLS) $(TESTS) $(EXAMPLES) modules/loxc_demo.o tools/loxc_bench2