Skip to content

Instantly share code, notes, and snippets.

@jwakely
Created May 11, 2014 11:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jwakely/4450be775abb8403eda9 to your computer and use it in GitHub Desktop.
Save jwakely/4450be775abb8403eda9 to your computer and use it in GitHub Desktop.
Makefile for Howard's dining philosophers benchmarks
URL := https://raw.githubusercontent.com/HowardHinnant/papers/master/dining_philosophers.html
ALGOS := SMART_POLITE SMART PERSISTENT ORDERED STD
TARGETS_ROUND := $(foreach algo,$(ALGOS),round-$(algo))
TARGETS_3D := $(foreach algo,$(ALGOS),3d-$(algo))
CXXFLAGS := -std=c++11 -O2 -pthread -Wall -Wno-sign-compare
# Define GCC_PATH to use a GCC from a non-standard path,
# this ensure the shared libraries will be found at run-time.
ifdef GCC_PATH
CXX := $(GCC_PATH)/bin/g++ -Wl,-rpath,$(GCC_PATH)/lib64
endif
.PHONY: all
all: $(TARGETS_ROUND) $(TARGETS_3D)
@for i in $^ ; do time ./$$i ; done
$(TARGETS_ROUND): round.cc std.h
$(CXX) $(CXXFLAGS) -D$(patsubst round-%,%,$@) $< -o $@
$(TARGETS_3D): 3d.cc std.h
$(CXX) $(CXXFLAGS) -D$(patsubst 3d-%,%,$@) $< -o $@
$(TARGETS_3D): CXXFLAGS += -include algorithm
round-STD 3d-STD: CXXFLAGS += -include std.h
std.h:
@echo '#include <mutex>' > $@
@echo 'using std::lock;' >> $@
round.cc: dining_philosophers.html
w3m -dump $< | sed -e '1,/^Appendix A/d' -e '/^Appendix B/,$$d' > $@
3d.cc: dining_philosophers.html
w3m -dump $< | sed -e '1,/^Appendix B/d' > $@
dining_philosophers.html:
curl -O $(URL)
.PHONY: clean
clean:
rm -f *.html *.cc $(TARGETS_ROUND) $(TARGETS_3D)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment