Skip to content

Commit f3f3b27

Browse files
committed
gpt2_webgpu_aot runs on mac after updating experimental/kernels/Makefile to point to updated dylib artifact, add note to third_party/lib/README.md regarding new dawn shared library build process
1 parent 254e4ea commit f3f3b27

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

experimental/kernels/Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ CXXFLAGS=-std=c++17 -I$(GPUCPP) -I$(GPUCPP)/third_party/headers -I. -Iunittest_l
1616
CFLAGS=-Ofast -march=native -I. -Iunittest_llmc
1717
# CFLAGS=-O2 -march=native -I. -Iunittest_llmc
1818

19-
LDFLAGS=$(STDLIB) -L$(GPUCPP)/third_party/lib -ldl -ldawn -fsanitize=address
19+
LDFLAGS=$(STDLIB) -L$(GPUCPP)/third_party/lib -ldl -lwebgpu_dawn -fsanitize=address
2020
FLAGS=$(CXXFLAGS) $(LDFLAGS)
2121

2222
ifeq ($(shell [ -d /opt/homebrew/opt/libomp/lib ] && echo "exists"), exists)
@@ -83,18 +83,18 @@ endef
8383
build/test_gpt2: llm.c build/unittest_kernels.o gpt2_124M.bin
8484
mkdir -p build
8585
$(call preprocess_file)
86-
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ llm.c/test_gpt2.c build/unittest_kernels.o -g
86+
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ llm.c/test_gpt2.c build/unittest_kernels.o
8787

8888
build/test_gpt2_with_metal_profiler: llm.c build/unittest_kernels.o gpt2_124M.bin
8989
mkdir -p build
9090
$(call preprocess_file)
9191
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ llm.c/test_gpt2.c build/unittest_kernels.o -I$(GPUCPP) $(GPUCPP)/experimental/profiler/metal.mm -framework metal -framework Foundation -DMETAL_PROFILER -g
92-
install_name_tool -change @rpath/libdawn.dylib $(GPUCPP)/third_party/lib/libdawn.dylib $@
92+
install_name_tool -change @rpath/libwebgpu_dawn.dylib $(GPUCPP)/third_party/lib/libwebgpu_dawn.dylib $@
9393

9494
build/train_gpt2: llm.c build/unittest_kernels.o gpt2_124M.bin
9595
mkdir -p build
9696
$(call preprocess_file)
97-
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ llm.c/train_gpt2.c build/unittest_kernels.o -g
97+
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ llm.c/train_gpt2.c build/unittest_kernels.o
9898

9999
build/ops.o: ops.cpp ops.hpp kernels.h llm.c
100100
mkdir -p build && $(CXX) $(CXXFLAGS) -c -o $@ $<
@@ -105,7 +105,7 @@ build/gpt2_webgpu: llm.c gpt2_124M.bin llm.c gpt2_webgpu.cpp ops.cpp
105105

106106
build/gpt2_webgpu_aot: llm.c gpt2_124M.bin llm.c gpt2_webgpu_aot.cpp ops_aot.cpp
107107
mkdir -p build
108-
$(CC) $(CXXFLAGS) -Illm.c $(LDFLAGS) -o $@ gpt2_webgpu_aot.cpp ops_aot.cpp -g
108+
$(CC) $(CXXFLAGS) -Illm.c $(LDFLAGS) -o $@ gpt2_webgpu_aot.cpp ops_aot.cpp
109109

110110
build/gpt2_webgpu.html: check-emsdk gpt2_webgpu.cpp term.html llm.c
111111
em++ gpt2_webgpu.cpp ops.cpp \
@@ -139,7 +139,7 @@ server: build/gpt2_webgpu.html
139139
build/unittest_kernels.o: unittest_llmc/unittest_kernels.cpp unittest_llmc/unittest_kernels.h kernels.h
140140
mkdir -p build && $(CXX) $(CXXFLAGS) -DNDEBUG -c -o $@ $<
141141

142-
dawnlib: $(if $(wildcard $(GPUCPP)/third_party/lib/libdawn.so $(GPUCPP)/third_party/lib/libdawn.dylib),,run_setup)
142+
dawnlib: $(if $(wildcard $(GPUCPP)/third_party/lib/libwebgpu_dawn.so $(GPUCPP)/third_party/lib/libwebgpu_dawn.dylib),,run_setup)
143143

144144
run_setup: check-python
145145
cd $(GPUCPP) && python3 setup.py

third_party/lib/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
# Release 0.2.0 (draft)
2+
3+
Switched from
4+
https://github.com/jspanchu/webgpu-dawn-binaries
5+
to building from the dawn repository:
6+
https://github.com/google/dawn
7+
8+
Commit hash:
9+
5a00ab1fbc22d6ebbab39c901c1f90144e9b71e9
10+
11+
Build with clang (assumes running from out/Release)
12+
13+
```
14+
cmake -DBUILD_SHARED_LIBS=ON -DDAWN_BUILD_MONOLITHIC_LIBRARY=ON -DCMAKE_BUILD_TYPE=Release ../..
15+
```
16+
Library artifact is at `src/dawn/native/libwebgpu_dawn.dylib` (7.4 MB)
17+
18+
# Release 0.1.0
19+
120
https://github.com/jspanchu/webgpu-dawn-binaries
221
commit hash:
322
c0602d5d0466040f6e080d6cb7209860538f9f8d

0 commit comments

Comments
 (0)