1515# 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
1616EMFLAGS=-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
1717CXXFLAGS=-std =c++17 -I$(GPUCPP ) -I$(GPUCPP ) /third_party/headers -I. -Iunittest_llmc
18- CXXFLAGS=-std =c++17 -I$(GPUCPP ) -I$(GPUCPP ) /third_party/headers -I. -Iunittest_llmc
1918CFLAGS =-Ofast -march=native -I. -Iunittest_llmc
2019
2120LDFLAGS =$(STDLIB ) -L$(GPUCPP ) /third_party/lib -ldl -ldawn
@@ -91,6 +90,13 @@ build/train_gpt2: llm.c build/unittest_kernels.o gpt2_124M.bin
9190 grep -q " ^#include \" unittest_kernels.h\" " llm.c/train_gpt2.c || sed -i ' 1i#include \"unittest_kernels.h\"' llm.c/train_gpt2.c
9291 $(CC ) $(CFLAGS ) $(LDFLAGS ) -o $@ llm.c/train_gpt2.c build/unittest_kernels.o
9392
93+ build/ops.o : ops.cpp ops.hpp kernels.h
94+ mkdir -p build && $(CXX ) $(CXXFLAGS ) -DNDEBUG -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
99+
94100build/test_gpt2.html : check-emsdk run.cpp term.html build/test_gpt2
95101 em++ llm.c/test_gpt2.c unittest_llmc/unittest_kernels.cpp \
96102 --preload-file gpt2_tokenizer.bin@/gpt2_tokenizer.bin \
@@ -114,7 +120,7 @@ build/train_gpt2.html: check-emsdk run.cpp term.html build/train_gpt2
114120 --shell-file term.html \
115121
116122build/gpt2_gpucpp.html : check-emsdk run.cpp term.html build/train_gpt2
117- em++ gpt2_wasm.c unittest_llmc/unittest_kernels.cpp \
123+ em++ gpt2_webgpu.cpp unittest_llmc/unittest_kernels.cpp \
118124 --preload-file gpt2_tokenizer.bin@/gpt2_tokenizer.bin \
119125 --preload-file gpt2_124M.bin@/gpt2_124M.bin \
120126 --preload-file gpt2_124M_debug_state.bin@/gpt2_124M_debug_state.bin \
@@ -124,9 +130,12 @@ build/gpt2_gpucpp.html: check-emsdk run.cpp term.html build/train_gpt2
124130 $(EMFLAGS ) \
125131 --shell-file term.html \
126132
127- watch :
133+ watch-web :
128134 ls * .cpp * .c * .hpp * .h | entr -c make build/gpt2_gpucpp.html
129135
136+ watch-native :
137+ ls * .cpp * .c * .hpp * .h | entr -c make build/train_gpt2
138+
130139server : build/train_gpt2.html build/test_gpt2.html build/gpt2_gpucpp.html
131140 @echo " \n┌───────────────────────────────────────────────────────────────────────────────────┐"
132141 @echo " │ Open http://localhost:8000/build/run.html in your browser to see the output. │"
0 commit comments