Skip to content

Commit d191ce0

Browse files
committed
fix field order of LIMITS_BUFFER_SIZE_1GB, add build targets for wasm, train_gpt2.c fork -> gpt2_webgpu.cpp
1 parent 98ec943 commit d191ce0

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

experimental/kernels/Makefile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ endif
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
1616
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
1717
CXXFLAGS=-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
1918
CFLAGS=-Ofast -march=native -I. -Iunittest_llmc
2019

2120
LDFLAGS=$(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+
94100
build/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

116122
build/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+
130139
server: 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. │"

experimental/kernels/ops.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ extern "C" {
77

88
// See https://github.com/google/dawn/blob/a8fbe981a86cb59536e2de423d2013a82d9b54a0/src/dawn/native/Limits.cpp
99
#define LIMITS_BUFFER_SIZE_1GB { \
10+
.nextInChain = nullptr, \
1011
.limits = { \
1112
.maxTextureDimension1D=8192, \
1213
.maxTextureDimension2D=8192, \
@@ -40,8 +41,7 @@ extern "C" {
4041
.maxComputeWorkgroupSizeY=256, \
4142
.maxComputeWorkgroupSizeZ=64, \
4243
.maxComputeWorkgroupsPerDimension=65535 \
43-
}, \
44-
.nextInChain = nullptr \
44+
} \
4545
}
4646

4747
// static std::unique_ptr<gpu::Context> kCtx;

experimental/kernels/unittest_llmc/unittest_kernels.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ using namespace gpu; // createContext, createTensor, createKernel,
1414

1515
// See https://github.com/google/dawn/blob/a8fbe981a86cb59536e2de423d2013a82d9b54a0/src/dawn/native/Limits.cpp
1616
#define LIMITS_BUFFER_SIZE_1GB { \
17+
.nextInChain = nullptr, \
1718
.limits = { \
1819
.maxTextureDimension1D=8192, \
1920
.maxTextureDimension2D=8192, \
@@ -47,8 +48,7 @@ using namespace gpu; // createContext, createTensor, createKernel,
4748
.maxComputeWorkgroupSizeY=256, \
4849
.maxComputeWorkgroupSizeZ=64, \
4950
.maxComputeWorkgroupsPerDimension=65535 \
50-
}, \
51-
.nextInChain = nullptr \
51+
} \
5252
}
5353

5454
void ENCODER_FORWARD_GPU(float* out,

0 commit comments

Comments
 (0)