# Collect benchmark: given n (key, value) pairs, combine all values with the
# same key. Two implementations:
#   -impl sort   sort by key, then reduce each run of equal keys (CollectSort.sml)
#   -impl hash   concurrent insert-and-combine into a hash table (CollectHash.sml)
#
#   make
#   bin/collect @mpl procs 8 -- -impl sort -n 10000000 -k 1000
#   bin/collect @mpl procs 8 -- -impl hash -n 10000000 -k 1000 --ticks
#
# Other flags: -seed S, -repeat R, -warmup W. Use --ticks to print per-phase timings.

MPL ?= mpl
SMLPKG ?= smlpkg
MPL_FLAGS ?= -default-type int64 -default-type word64

MPLLIB = lib/github.com/mpllang/mpllib/sources.mpl.mlb

.PHONY: all clean realclean

all: bin/collect

bin/collect: $(MPLLIB) collect.mlb *.sml ../Concurrency.sml
	@mkdir -p bin
	$(MPL) $(MPL_FLAGS) -output $@ collect.mlb

$(MPLLIB): sml.pkg
	$(SMLPKG) sync
	@touch $@

clean:
	rm -rf bin

realclean: clean
	rm -rf lib
