|
15 | 15 | # EMFLAGS=-std=c++17 -I$(GPUCPP) -I$(GPUCPP)/third_party/headers/wasm -I. -Iunittest_llmc -Illm.c -s USE_WEBGPU=1 -s -s STACK_SIZE=100000 -s MEMORY64=1 -s ALLOW_MEMORY_GROWTH=1 |
16 | 16 | EMFLAGS=-std=c++17 -I$(GPUCPP) -I$(GPUCPP)/third_party/headers/wasm -I. -Iunittest_llmc -Illm.c -s USE_WEBGPU=1 -s ASYNCIFY=1 -s STACK_SIZE=100000 -s MEMORY64=1 -s ALLOW_MEMORY_GROWTH=1 |
17 | 17 | CXXFLAGS=-std=c++17 -I$(GPUCPP) -I$(GPUCPP)/third_party/headers -I. -Iunittest_llmc |
18 | | -CFLAGS=-Ofast -march=native -I. -Iunittest_llmc |
| 18 | +# CFLAGS=-Ofast -march=native -I. -Iunittest_llmc |
| 19 | +CFLAGS=-O2 -march=native -I. -Iunittest_llmc |
19 | 20 |
|
20 | 21 | LDFLAGS=$(STDLIB) -L$(GPUCPP)/third_party/lib -ldl -ldawn |
21 | 22 | FLAGS=$(CXXFLAGS) $(LDFLAGS) |
@@ -91,48 +92,34 @@ build/train_gpt2: llm.c build/unittest_kernels.o gpt2_124M.bin |
91 | 92 | $(CC) $(CFLAGS) $(LDFLAGS) -o $@ llm.c/train_gpt2.c build/unittest_kernels.o |
92 | 93 |
|
93 | 94 | build/ops.o: ops.cpp ops.hpp kernels.h |
94 | | - mkdir -p build && $(CXX) $(CXXFLAGS) -g -c -o $@ $< |
95 | | - |
96 | | -# build/gpt2_webgpu: llm.c build/ops.o gpt2_124M.bin |
97 | | -# mkdir -p build |
98 | | -# $(CC) -g $(CXXFLAGS) -Illm.c $(LDFLAGS) -o $@ gpt2_webgpu.cpp build/ops.o |
| 95 | + mkdir -p build && $(CXX) $(CXXFLAGS) -c -o $@ $< |
99 | 96 |
|
100 | 97 | build/gpt2_webgpu: llm.c gpt2_124M.bin |
101 | 98 | mkdir -p build |
102 | | - $(CC) -g $(CXXFLAGS) -Illm.c $(LDFLAGS) -o $@ gpt2_webgpu.cpp ops.cpp |
103 | | - |
104 | | -build/test_gpt2.html: check-emsdk run.cpp term.html build/test_gpt2 |
105 | | - em++ llm.c/test_gpt2.c unittest_llmc/unittest_kernels.cpp \ |
106 | | - --preload-file gpt2_tokenizer.bin@/gpt2_tokenizer.bin \ |
107 | | - --preload-file gpt2_124M.bin@/gpt2_124M.bin \ |
108 | | - --preload-file gpt2_124M_debug_state.bin@/gpt2_124M_debug_state.bin \ |
109 | | - --preload-file llm.c/dev/data/tinyshakespeare/tiny_shakespeare_train.bin@dev/data/tinyshakespeare/tiny_shakespeare_train.bin \ |
110 | | - --preload-file llm.c/dev/data/tinyshakespeare/tiny_shakespeare_val.bin@dev/data/tinyshakespeare/tiny_shakespeare_val.bin \ |
111 | | - -o build/test_gpt2.html \ |
112 | | - $(EMFLAGS) \ |
113 | | - --shell-file term.html \ |
| 99 | + $(CC) $(CXXFLAGS) -Illm.c $(LDFLAGS) -o $@ gpt2_webgpu.cpp ops.cpp |
114 | 100 |
|
115 | | -build/train_gpt2.html: check-emsdk run.cpp term.html build/train_gpt2 |
116 | | - em++ llm.c/train_gpt2.c unittest_llmc/unittest_kernels.cpp \ |
| 101 | +build/gpt2_webgpu.html: check-emsdk gpt2_webgpu.cpp term.html |
| 102 | + em++ gpt2_webgpu.cpp ops.cpp \ |
117 | 103 | --preload-file gpt2_tokenizer.bin@/gpt2_tokenizer.bin \ |
118 | 104 | --preload-file gpt2_124M.bin@/gpt2_124M.bin \ |
119 | 105 | --preload-file gpt2_124M_debug_state.bin@/gpt2_124M_debug_state.bin \ |
120 | 106 | --preload-file llm.c/dev/data/tinyshakespeare/tiny_shakespeare_train.bin@dev/data/tinyshakespeare/tiny_shakespeare_train.bin \ |
121 | 107 | --preload-file llm.c/dev/data/tinyshakespeare/tiny_shakespeare_val.bin@dev/data/tinyshakespeare/tiny_shakespeare_val.bin \ |
122 | | - -o build/train_gpt2.html \ |
| 108 | + -o build/gpt2_webgpu.html \ |
123 | 109 | $(EMFLAGS) \ |
124 | 110 | --shell-file term.html \ |
125 | 111 |
|
126 | 112 | watch-web: |
127 | | - ls *.cpp *.c *.hpp *.h | entr -s make build/gpt2_gpucpp.html |
| 113 | + ls *.cpp *.c *.hpp *.h | entr -s make build/gpt2_webgpu.html |
128 | 114 |
|
129 | 115 | watch-native: |
130 | 116 | ls *.cpp *.c *.hpp *.h | entr -s "rm -f build/gpt2_webgpu && rm -f build/ops.o && make build/gpt2_webgpu" |
131 | 117 |
|
132 | 118 | run-native: build/gpt2_webgpu |
133 | 119 | . $(GPUCPP)/source && ./build/gpt2_webgpu |
134 | 120 |
|
135 | | -server: build/train_gpt2.html build/test_gpt2.html build/gpt2_gpucpp.html |
| 121 | +# server: build/train_gpt2.html build/test_gpt2.html build/gpt2_gpucpp.html |
| 122 | +server: build/gpt2_webgpu.html |
136 | 123 | @echo "\n┌───────────────────────────────────────────────────────────────────────────────────┐" |
137 | 124 | @echo "│ Open http://localhost:8000/build/run.html in your browser to see the output. │" |
138 | 125 | @echo "│ │" |
|
0 commit comments