/ concept-collection / turing-sphere
Sign in
concept-collection / turing-sphere
58 lines · 1.9 KBBlameHistoryRaw
1# Native SHTNS benchmarks, to compare against the WGSL transforms in ../../src/sht.
2#
3# ./bootstrap.sh # fetch and build upstream SHTNS, write shtns.mk
4# make # shtbench, plus shtbench_gpu if SHTNS has CUDA support
5#
6# -ffast-math is deliberately NOT used: the fp32 GPU run is compared element by
7# element against the WebGPU one, and reassociation would make that a comparison
8# of two different computations. -O3 without it is what SHTNS' own codelets use.
10-include shtns.mk
12ifeq ($(SHTNS_LIB),)
13$(error run ./bootstrap.sh first — it fetches SHTNS and writes shtns.mk)
14endif
16CXX ?= g++
17NVCC ?= nvcc
18# Compile for the GPUs in this machine, which is both the fastest build and the
19# right answer for a benchmark that only ever runs here. Needs CUDA 11.5+; on an
20# older toolkit, or to build elsewhere and run here, say
21# `make NVCC_ARCH=-arch=sm_80`.
22NVCC_ARCH ?= -arch=native
24CXXFLAGS ?= -O3 -march=native -std=c++14 -fopenmp -Wall -Wextra -Wno-unused-parameter
25NVCCFLAGS ?= -O3 -std=c++14 -lineinfo
26INCLUDES = -I$(SHTNS_DIR)
27LDLIBS = $(SHTNS_LIB) $(SHTNS_LDLIBS)
29TARGETS = shtbench
30ifeq ($(SHTNS_HAS_GPU),1)
31TARGETS += shtbench_gpu
32endif
34all: $(TARGETS)
35 @echo
36 @echo "built: $(TARGETS)"
37ifneq ($(SHTNS_HAS_GPU),1)
38 @echo "note: SHTNS was built without GPU support, so there is no shtbench_gpu."
39 @echo " Re-run ./bootstrap.sh on a machine with nvcc to get it."
40endif
42shtbench: shtbench.cpp spec.h
43 $(CXX) $(CXXFLAGS) $(INCLUDES) $< -o $@ $(LDLIBS)
45# nvcc drives the link so the CUDA runtime and the C++ standard library (which
46# SHTNS' .cu objects need) come along without naming them by hand.
47shtbench_gpu: shtbench_gpu.cu spec.h
48 $(NVCC) $(NVCCFLAGS) $(NVCC_ARCH) $(INCLUDES) $< -o $@ \
49 -Xcompiler -fopenmp $(LDLIBS)
51clean:
52 rm -f shtbench shtbench_gpu
54# Also throws away the SHTNS checkout and shtns.mk; ./bootstrap.sh rebuilds them.
55distclean: clean
56 rm -rf $(SHTNS_DIR) shtns.mk
58.PHONY: all clean distclean
moveopenescclose