Skip to content

Commit f9d9819

Browse files
committed
fix test_kernels build, clean up makefile
1 parent 53d0fea commit f9d9819

File tree

2 files changed

+36
-41
lines changed

2 files changed

+36
-41
lines changed

Makefile

+35-40
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,21 @@ TARGET_TESTS=run_tests
55
TARGET_LIB=gpu
66
TARGET_ALL=$(TARGET_DEMO) $(TARGET_TESTS) $(TARGET_LIB)
77
USE_LOCAL=-DUSE_LOCAL_LIBS=ON
8-
USE_WGPU=-DWEBGPU_TAG=wgpu
98

109
.PHONY: demo tests libgpu debug build check-entr watch-demo watch-tests clean
1110

1211
# Add --trace to see the cmake commands
13-
# absl c++20 check is breaking mac builds
1412
FLAGS = -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_CXX_COMPILER=$(CXX) -DABSL_INTERNAL_AT_LEAST_CXX20=OFF
1513

16-
# TODO(avh): decide whether to use wgpu as default
1714
FASTBUILD_FLAGS = $(FLAGS) -DFASTBUILD:BOOL=ON
18-
RELEASE_FLAGS = $(FLAGS) -DFASTBUILD:BOOL=OFF
1915
DEBUG_FLAGS = $(FLAGS) -DDEBUG:BOOL=ON
20-
# EMSCRIPTEN_FLAGS = -DIMPLEMENTATION=emscripten -DCMAKE_TOOLCHAIN_FILE=../cmake/emscripten.cmake -DCMAKE_CXX_COMPILER=em++
21-
EMSCRIPTEN_FLAGS = -DIMPLEMENTATION=emscripten -DCMAKE_CXX_COMPILER=em++
16+
RELEASE_FLAGS = $(FLAGS) -DFASTBUILD:BOOL=OFF
2217
LOCAL_FLAGS = -DUSE_LOCAL_LIBS=ON
23-
24-
# CMAKE command variable
2518
CMAKE_CMD = mkdir -p build && cd build && cmake ..
2619

2720
demo: check-dependencies
2821
$(CMAKE_CMD) $(FASTBUILD_FLAGS) && make -j$(NUM_JOBS) $(TARGET_DEMO) && ./$(TARGET_DEMO)
2922

30-
# check for the existence of clang++ and cmake
31-
check-dependencies:
32-
@command -v clang++ >/dev/null 2>&1 || { echo >&2 "Please install clang++ with 'sudo apt-get install clang' or 'brew install llvm'"; exit 1; }
33-
@command -v cmake >/dev/null 2>&1 || { echo >&2 "Please install cmake with 'sudo apt-get install cmake' or 'brew install cmake'"; exit 1; }
34-
3523
tests: check-dependencies
3624
$(CMAKE_CMD) $(FASTBUILD_FLAGS) && make -j$(NUM_JOBS) $(TARGET_TESTS) && ./$(TARGET_TESTS)
3725

@@ -41,43 +29,50 @@ libgpu: check-dependencies
4129
debug: check-dependencies
4230
$(CMAKE_CMD) $(DEBUG_FLAGS) && make -j$(NUM_JOBS) $(TARGET_ALL)
4331

44-
debug-wgpu: check-dependencies
45-
$(CMAKE_CMD) $(DEBUG_FLAGS) $(USE_WGPU) && make -j$(NUM_JOBS) $(TARGET_ALL)
46-
4732
build: check-dependencies
4833
$(CMAKE_CMD) $(RELEASE_FLAGS) && make -j$(NUM_JOBS) $(TARGET_ALL)
4934

50-
emscripten: check-dependencies
51-
$(CMAKE_CMD) $(EMSCRIPTEN_FLAGS) -DIMPLEMENTATION=emscripten && make -j$(NUM_JOBS) $(TARGET_ALL)
52-
53-
check-entr:
54-
@command -v entr >/dev/null 2>&1 || { echo >&2 "Please install entr with 'brew install entr' or 'sudo apt-get install entr'"; exit 1; }
55-
56-
watch-demo: check-entr check-dependencies
57-
$(CMAKE_CMD) $(FASTBUILD_FLAGS) && ls ../* ../utils/* | entr -s "rm -f $(TARGET_DEMO) && make -j$(NUM_JOBS) $(TARGET_DEMO) && ./$(TARGET_DEMO)"
58-
5935
watch-tests: check-entr check-dependencies
6036
$(CMAKE_CMD) $(FASTBUILD_FLAGS) && ls ../utils/test_kernels.cpp ../*.h ../utils/*.h ../nn/*.h | entr -s "rm -f $(TARGET_TESTS) && make -j$(NUM_JOBS) $(TARGET_TESTS) && ./$(TARGET_TESTS)"
6137

62-
# experimental
63-
watch-tests-wgpu: check-entr check-dependencies
64-
# export RUST_TRACE=1
65-
$(CMAKE_CMD) $(FASTBUILD_FLAGS) $(USE_WGPU) && ls ../* ../utils/* | entr -s "rm -f $(TARGET_TESTS) && make -j$(NUM_JOBS) $(TARGET_TESTS) && ./$(TARGET_TESTS)"
66-
67-
watch-demo-local: check-entr check-dependencies
68-
$(CMAKE_CMD) $(FASTBUILD_FLAGS) $(LOCAL_FLAGS) && ls ../* ../utils/* | entr -s "rm -f $(TARGET_DEMO) && make -j$(NUM_JOBS) $(TARGET_DEMO) && ./$(TARGET_DEMO)"
69-
70-
watch-tests-local: check-entr check-dependencies
71-
$(CMAKE_CMD) $(FASTBUILD_FLAGS) $(LOCAL_FLAGS) && ls ../* ../utils/* | entr -s "rm -f $(TARGET_TESTS) && make -j$(NUM_JOBS) $(TARGET_TESTS) && ./$(TARGET_TESTS)"
38+
all: build
39+
cd examples/gpu_puzzles && make
40+
cd examples/hello_world && make
41+
cd examples/raymarch && make
42+
cd examples/webgpu_intro && make
7243

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

7647
clean:
7748
read -r -p "This will delete the contents of build/* and third_party/*. Are you sure? [CTRL-C to abort] " response && rm -rf build/* third_party/fetchcontent/* third_party/gpu-build third_party/gpu-subbuild third_party/gpu-src
7849

79-
all: build
80-
cd examples/gpu_puzzles && make
81-
cd examples/hello_world && make
82-
cd eamples/raymarch && make
83-
cd examples/webgpu_intro && make
50+
################################################################################
51+
# Checks
52+
################################################################################
53+
54+
# check for the existence of clang++ and cmake
55+
check-dependencies:
56+
@command -v clang++ >/dev/null 2>&1 || { echo >&2 "Please install clang++ with 'sudo apt-get install clang' or 'brew install llvm'"; exit 1; }
57+
@command -v cmake >/dev/null 2>&1 || { echo >&2 "Please install cmake with 'sudo apt-get install cmake' or 'brew install cmake'"; exit 1; }
58+
59+
check-entr:
60+
@command -v entr >/dev/null 2>&1 || { echo >&2 "Please install entr with 'brew install entr' or 'sudo apt-get install entr'"; exit 1; }
61+
62+
################################################################################
63+
# Experimental targets (not tested / not working)
64+
################################################################################
65+
66+
USE_WGPU=-DWEBGPU_TAG=wgpu
67+
# EMSCRIPTEN_FLAGS = -DIMPLEMENTATION=emscripten -DCMAKE_TOOLCHAIN_FILE=../cmake/emscripten.cmake -DCMAKE_CXX_COMPILER=em++
68+
EMSCRIPTEN_FLAGS = -DIMPLEMENTATION=emscripten -DCMAKE_CXX_COMPILER=em++
69+
70+
debug-wgpu: check-dependencies
71+
$(CMAKE_CMD) $(DEBUG_FLAGS) $(USE_WGPU) && make -j$(NUM_JOBS) $(TARGET_ALL)
72+
73+
watch-tests-wgpu: check-entr check-dependencies
74+
# export RUST_TRACE=1
75+
$(CMAKE_CMD) $(FASTBUILD_FLAGS) $(USE_WGPU) && ls ../* ../utils/* | entr -s "rm -f $(TARGET_TESTS) && make -j$(NUM_JOBS) $(TARGET_TESTS) && ./$(TARGET_TESTS)"
76+
77+
emscripten: check-dependencies
78+
$(CMAKE_CMD) $(EMSCRIPTEN_FLAGS) -DIMPLEMENTATION=emscripten && make -j$(NUM_JOBS) $(TARGET_ALL)

utils/test_kernels.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ void TestMultiKernel2(Context &ctx) {
366366
}
367367

368368
int main(int argc, char **argv) {
369-
Context ctx = CreateContext(/* verbose logging */ false);
369+
Context ctx = CreateContext();
370370

371371
TestTensorPool(ctx);
372372
TestResidual(ctx);

0 commit comments

Comments
 (0)