NUM_JOBS=$(shell nproc)CXX=clang++.PHONY: default examples/hello_world/build/hello_world tests libgpu debug build check-clang clean-build clean all watch-tests docsGPUCPP ?= $(PWD)LIBDIR ?= $(GPUCPP)/third_party/libLIBSPEC ?= . $(GPUCPP)/sourceINCLUDES ?= -I$(GPUCPP) -I$(GPUCPP)/third_party/headersifeq ($(shell $(CXX) -std=c++17 -x c++ -E -include array - < /dev/null > /dev/null 2>&1 ; echo $$?),0)STDLIB :=elseSTDLIB := -stdlib=libc++endifdefault: examples/hello_world/build/hello_worldpch:mkdir -p build && $(CXX) -std=c++17 $(INCLUDES) -x c++-header gpu.hpp -o build/gpu.hpp.pch# TODO(avh): change extension based on platform# Get the current OS nameOS = $(shell uname | tr -d '\n')# Set the specific variables for each platformLIB_PATH ?= /usr/libHEADER_PATH ?= /usr/includeifeq ($(OS), Linux)OS_TYPE ?= LinuxGPU_CPP_LIB_NAME ?= libgpucpp.soDAWN_LIB_NAME ?= libwebgpu_dawn.soelse ifeq ($(OS), Darwin)OS_TYPE ?= macOSGPU_CPP_LIB_NAME ?= libgpucpp.dylibDAWN_LIB_NAME ?= libwebgpu_dawn.dylibelseOS_TYPE ?= unknownendiflib: check-clang dawnlibmkdir -p build && $(CXX) -std=c++17 $(INCLUDES) -L$(LIBDIR) -lwebgpu_dawn -ldl -shared -fPIC gpu.cpp -o build/$(GPU_CPP_LIB_NAME)python3 build.pycp third_party/lib/$(DAWN_LIB_NAME) build/install:cp build/$(GPU_CPP_LIB_NAME) $(LIB_PATH)cp build/$(DAWN_LIB_NAME) $(LIB_PATH)cp build/gpu.hpp $(HEADER_PATH)uninstall:rm $(LIB_PATH)/$(GPU_CPP_LIB_NAME)rm $(LIB_PATH)/$(DAWN_LIB_NAME)rm $(HEADER_PATH)/gpu.hppexamples/hello_world/build/hello_world: check-clang dawnlib examples/hello_world/run.cpp check-linux-vulkan$(LIBSPEC) && cd examples/hello_world && make build/hello_world && ./build/hello_worlddawnlib: $(if $(wildcard third_party/lib/libwebgpu_dawn.so third_party/lib/libwebgpu_dawn.dylib),,run_setup)run_setup: check-pythonpython3 setup.pyall: dawnlib check-clang check-linux-vulkan lib pchcd examples/float16 && make build/float16cd examples/gpu_puzzles && make build/gpu_puzzlescd examples/hello_world && make build/hello_worldcd examples/matmul && make build/matmulcd examples/physics && make build/physicscd examples/render && make build/rendercd examples/shadertui && make build/shadertuicd examples/transpose && make build/transpose# Test 16-bit floating point typetest-half: dawnlib check-clang$(LIBSPEC) && clang++ -std=c++17 $(INCLUDES) numeric_types/half.cpp -L$(LIBDIR) -lwebgpu_dawn -ldl -o build/half && ./build/halfdocs: Doxyfiledoxygen Doxyfile################################################################################# cmake targets (optional - precompiled binaries is preferred)################################################################################CMAKE_CMD = mkdir -p build && cd build && cmake ..# Add --trace to see the cmake commandsFLAGS = -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_CXX_COMPILER=$(CXX) -DABSL_INTERNAL_AT_LEAST_CXX20=OFFFASTBUILD_FLAGS = $(FLAGS) -DFASTBUILD:BOOL=ONDEBUG_FLAGS = $(FLAGS) -DDEBUG:BOOL=ONRELEASE_FLAGS = $(FLAGS) -DFASTBUILD:BOOL=OFFTARGET_LIB=gpulibgpu-cmake: check-clang check-cmake$(CMAKE_CMD) $(RELEASE_FLAGS) && make -j$(NUM_JOBS) gpudebug-cmake: check-clang check-cmake$(CMAKE_CMD) $(DEBUG_FLAGS) && make -j$(NUM_JOBS) $(TARGET_ALL)all-cmake: check-clang check-cmake$(CMAKE_CMD) $(RELEASE_FLAGS) && make -j$(NUM_JOBS) $(TARGET_ALL)################################################################################# Cleanup################################################################################clean-dawnlib:rm -f third_party/lib/libwebgpu_dawn.so third_party/lib/libwebgpu_dawn.dylibclean:read -r -p "This will delete the contents of build/*. Are you sure? [CTRL-C to abort] " response && rm -rf build/*rm -rf examples/float16/build/*rm -rf examples/gpu_puzzles/build/*rm -rf examples/hello_world/build/*rm -rf examples/matmul/build/matmulrm -rf examples/physics/build/*rm -rf examples/render/build/*rm -rf examples/shadertui/build/*rm -rf examples/transpose/build/transposerm -f build/gpu.hpp.pchrm -f build/libgpucpp.sorm -f build/halfclean-all: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 third_party/lib/libwebgpu_dawn.so third_party/lib/libwebgpu_dawn.dylib################################################################################# Checks################################################################################# Check allcheck-all: check-os check-clang check-cmake check-python# check the oscheck-os:ifeq ($(OS_TYPE), unknown)$(error Unsupported operating system)endif# check for the existence of clang++ and cmakecheck-clang:@command -v clang++ >/dev/null 2>&1 || { echo -e >&2 "Clang++ is not installed. Please install clang++ to continue.\nOn Debian / Ubuntu: 'sudo apt-get install clang' or 'brew install llvm'\nOn Centos: 'sudo yum install clang'"; exit 1; }check-cmake:@command -v cmake >/dev/null 2>&1 || { echo -e >&2 "Cmake is not installed. Please install cmake to continue.\nOn Debian / Ubuntu: 'sudo apt-get install cmake' or 'brew install cmake'\nOn Centos: 'sudo yum install cmake'"; exit 1; }check-python:@command -v python3 >/dev/null 2>&1 || { echo -e >&2 "Python is not installed. Please install python to continue.\nOn Debian / Ubuntu: 'sudo apt-get install python'\nOn Centos: 'sudo yum install python'"; exit 1; }check-linux-vulkan:@echo "Checking system type and Vulkan availability..."@if [ "$$(uname)" = "Linux" ]; then \if command -v vulkaninfo >/dev/null 2>&1; then \echo "Vulkan is installed."; \vulkaninfo; \else \echo -e "Vulkan is not installed. Please install Vulkan drivers to continue.\nOn Debian / Ubuntu: 'sudo apt install libvulkan1 mesa-vulkan-drivers vulkan-tools'.\nOn Centos: 'sudo yum install vulkan vulkan-tools.'"; \exit 1; \fi \else \echo "Non-Linux system detected. Skipping Vulkan check."; \fi
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。