Skip to content

Commit e58f612

Browse files
committed
pass context into ops for gpt_webgpu and ops, remove cpu/dpu dispatch
1 parent d191ce0 commit e58f612

File tree

4 files changed

+288
-869
lines changed

4 files changed

+288
-869
lines changed

experimental/kernels/Makefile

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,15 @@ build/train_gpt2: llm.c build/unittest_kernels.o gpt2_124M.bin
9191
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ llm.c/train_gpt2.c build/unittest_kernels.o
9292

9393
build/ops.o: ops.cpp ops.hpp kernels.h
94-
mkdir -p build && $(CXX) $(CXXFLAGS) -DNDEBUG -c -o $@ $<
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
9599

96-
build/gpt2_webgpu: llm.c build/ops.o gpt2_124M.bin
100+
build/gpt2_webgpu: llm.c gpt2_124M.bin
97101
mkdir -p build
98-
$(CC) -g $(CXXFLAGS) -Illm.c $(LDFLAGS) -o $@ gpt2_webgpu.cpp build/ops.o
102+
$(CC) -g $(CXXFLAGS) -Illm.c $(LDFLAGS) -o $@ gpt2_webgpu.cpp ops.cpp
99103

100104
build/test_gpt2.html: check-emsdk run.cpp term.html build/test_gpt2
101105
em++ llm.c/test_gpt2.c unittest_llmc/unittest_kernels.cpp \
@@ -119,22 +123,14 @@ build/train_gpt2.html: check-emsdk run.cpp term.html build/train_gpt2
119123
$(EMFLAGS) \
120124
--shell-file term.html \
121125

122-
build/gpt2_gpucpp.html: check-emsdk run.cpp term.html build/train_gpt2
123-
em++ gpt2_webgpu.cpp unittest_llmc/unittest_kernels.cpp \
124-
--preload-file gpt2_tokenizer.bin@/gpt2_tokenizer.bin \
125-
--preload-file gpt2_124M.bin@/gpt2_124M.bin \
126-
--preload-file gpt2_124M_debug_state.bin@/gpt2_124M_debug_state.bin \
127-
--preload-file llm.c/dev/data/tinyshakespeare/tiny_shakespeare_train.bin@dev/data/tinyshakespeare/tiny_shakespeare_train.bin \
128-
--preload-file llm.c/dev/data/tinyshakespeare/tiny_shakespeare_val.bin@dev/data/tinyshakespeare/tiny_shakespeare_val.bin \
129-
-o build/gpt2_gpucpp.html \
130-
$(EMFLAGS) \
131-
--shell-file term.html \
132-
133126
watch-web:
134-
ls *.cpp *.c *.hpp *.h | entr -c make build/gpt2_gpucpp.html
127+
ls *.cpp *.c *.hpp *.h | entr -s make build/gpt2_gpucpp.html
135128

136129
watch-native:
137-
ls *.cpp *.c *.hpp *.h | entr -c make build/train_gpt2
130+
ls *.cpp *.c *.hpp *.h | entr -s "rm -f build/gpt2_webgpu && rm -f build/ops.o && make build/gpt2_webgpu"
131+
132+
run-native: build/gpt2_webgpu
133+
. $(GPUCPP)/source && ./build/gpt2_webgpu
138134

139135
server: build/train_gpt2.html build/test_gpt2.html build/gpt2_gpucpp.html
140136
@echo "\n┌───────────────────────────────────────────────────────────────────────────────────┐"
@@ -152,11 +148,11 @@ dawnlib: $(if $(wildcard $(GPUCPP)/third_party/lib/libdawn.so $(GPUCPP)/third_pa
152148
run_setup: check-python
153149
cd $(GPUCPP) && python3 setup.py
154150

155-
build/$(TARGET): run.cpp
156-
mkdir -p build && $(CXX) $(FLAGS) -DNDEBUG -o $@ $<
151+
#build/$(TARGET): run.cpp
152+
# mkdir -p build && $(CXX) $(FLAGS) -DNDEBUG -o $@ $<
157153

158-
debug: run.cpp
159-
mkdir -p build && $(CXX) $(FLAGS) -g -o ./build/$(TARGET) $<
154+
#debug: run.cpp
155+
# mkdir -p build && $(CXX) $(FLAGS) -g -o ./build/$(TARGET) $<
160156

161157
clean:
162158
read -r -p "This will delete the contents of build/*. Are you sure? [CTRL-C to abort] " response && rm -rf build/*

0 commit comments

Comments
 (0)