<commit_before>CC ?= gcc
CFLAGS_common ?= -Wall -std=gnu99 -g
CPPFLAGS_common ?= -I../../include -Wall -g
CFLAGS_orig = -O0
CFLAGS_opt  = -O0

MODE ?= debug
SNAPPY ?= 0

EXEC = phonebook_orig phonebook_opt phonebook_hash phonebook_trie phonebook_rbtree phonebook_bptree phonebook_bptree_bulk
all: $(EXEC)

SRCS_common = main.c memory_pool.c

phonebook_orig: $(SRCS_common) phonebook_orig.c phonebook_orig.h
	$(CC) $(CFLAGS_common) $(CFLAGS_orig) \
		-DIMPL="\"$@.h\"" -o $@ \
		$(SRCS_common) $@.c

phonebook_opt: $(SRCS_common) phonebook_opt.c phonebook_opt.h
	$(CC) $(CFLAGS_common) $(CFLAGS_opt) \
		-DIMPL="\"$@.h\"" -DOPT -o $@ \
		$(SRCS_common) $@.c

phonebook_hash: $(SRCS_common) phonebook_opt.c phonebook_opt.h
	$(CC) $(CFLAGS_common) $(CFLAGS_opt) \
		-DIMPL="\"phonebook_opt.h\"" -DHASH -o $@ \
		$(SRCS_common) phonebook_opt.c

phonebook_trie: $(SRCS_common) phonebook_trie.c phonebook_trie.h
	$(CC) $(CFLAGS_common) $(CFLAGS_opt) \
		-DIMPL="\"$@.h\"" -DTRIE -o $@ \
		$(SRCS_common) $@.c

phonebook_rbtree: $(SRCS_common) phonebook_rbtree.c phonebook_rbtree.h
	$(CC) $(CFLAGS_common) $(CFLAGS_opt) \
		-DIMPL="\"$@.h\"" -DRBTREE -o $@ \
		$(SRCS_common) $@.c

phonebook_bptree: $(SRCS_common) ../../bplus.a
	$(CXX) $(CPPFLAGS_common) $(CFLAGS_opt) \
		-DIMPL="\"phonebook_orig.h\"" -DBPTREE -o $@ \
		$(SRCS_common) ../../bplus.a -lpthread

#<<<<<<< HEAD
#phonebook_bptree_bulk: $(SRCS_common) ../../bplus.a 
#	$(CXX) -Wall -lm $(CFLAGS_opt) \
		-I../../include -pthread \
		 -DIMPL="\"phonebook_orig.h\"" -DBPTREE_BULK -o $@ \
		$(SRCS_common) ../../bplus.a 
#=======
phonebook_bptree_bulk: $(SRCS_common) ../../bplus.a
	$(CXX) $(CPPFLAGS_common) $(CFLAGS_opt) \
		-DIMPL="\"phonebook_orig.h\"" -DBPTREE_BULK -o $@ \
		$(SRCS_common) ../../bplus.a -lpthread
#>>>>>>> upstream2/master

../../bplus.a:
	$(MAKE) -C ../.. MODE=$(MODE) SNAPPY=$(SNAPPY)

run: $(EXEC)
	echo 3 | sudo tee /proc/sys/vm/drop_caches
	watch -d -t "./phonebook_orig && echo 3 | sudo tee /proc/sys/vm/drop_caches"

cache-test: $(EXEC)
	perf stat --repeat 100 \
		-e cache-misses,cache-references,instructions,cycles \
		./phonebook_orig
	perf stat --repeat 100 \
		-e cache-misses,cache-references,instructions,cycles \
		./phonebook_opt
	perf stat --repeat 100 \
		-e cache-misses,cache-references,instructions,cycles \
		./phonebook_hash
	perf stat --repeat 100 \
		-e cache-misses,cache-references,instructions,cycles \
		./phonebook_trie<commit_msg>change -lpthread to -pthread in bptree<commit_after>CC ?= gcc
CFLAGS_common ?= -Wall -std=gnu99 -g
CPPFLAGS_common ?= -I../../include -Wall -g
CFLAGS_orig = -O0
CFLAGS_opt  = -O0

MODE ?= debug
SNAPPY ?= 0

EXEC = phonebook_orig phonebook_opt phonebook_hash phonebook_trie phonebook_rbtree phonebook_bptree phonebook_bptree_bulk
all: $(EXEC)

SRCS_common = main.c memory_pool.c

phonebook_orig: $(SRCS_common) phonebook_orig.c phonebook_orig.h
	$(CC) $(CFLAGS_common) $(CFLAGS_orig) \
		-DIMPL="\"$@.h\"" -o $@ \
		$(SRCS_common) $@.c

phonebook_opt: $(SRCS_common) phonebook_opt.c phonebook_opt.h
	$(CC) $(CFLAGS_common) $(CFLAGS_opt) \
		-DIMPL="\"$@.h\"" -DOPT -o $@ \
		$(SRCS_common) $@.c

phonebook_hash: $(SRCS_common) phonebook_opt.c phonebook_opt.h
	$(CC) $(CFLAGS_common) $(CFLAGS_opt) \
		-DIMPL="\"phonebook_opt.h\"" -DHASH -o $@ \
		$(SRCS_common) phonebook_opt.c

phonebook_trie: $(SRCS_common) phonebook_trie.c phonebook_trie.h
	$(CC) $(CFLAGS_common) $(CFLAGS_opt) \
		-DIMPL="\"$@.h\"" -DTRIE -o $@ \
		$(SRCS_common) $@.c

phonebook_rbtree: $(SRCS_common) phonebook_rbtree.c phonebook_rbtree.h
	$(CC) $(CFLAGS_common) $(CFLAGS_opt) \
		-DIMPL="\"$@.h\"" -DRBTREE -o $@ \
		$(SRCS_common) $@.c

phonebook_bptree: $(SRCS_common) ../../bplus.a
	$(CXX) $(CPPFLAGS_common) $(CFLAGS_opt) \
		-DIMPL="\"phonebook_orig.h\"" -DBPTREE -pthread -o $@ \
		$(SRCS_common) ../../bplus.a 

#<<<<<<< HEAD
#phonebook_bptree_bulk: $(SRCS_common) ../../bplus.a 
#	$(CXX) -Wall -lm $(CFLAGS_opt) \
		-I../../include -pthread \
		 -DIMPL="\"phonebook_orig.h\"" -DBPTREE_BULK -o $@ \
		$(SRCS_common) ../../bplus.a 
#=======
phonebook_bptree_bulk: $(SRCS_common) ../../bplus.a
	$(CXX) $(CPPFLAGS_common) $(CFLAGS_opt) \
		-DIMPL="\"phonebook_orig.h\"" -DBPTREE_BULK -pthread -o $@ \
		$(SRCS_common) ../../bplus.a 
#>>>>>>> upstream2/master

../../bplus.a:
	$(MAKE) -C ../.. MODE=$(MODE) SNAPPY=$(SNAPPY)

run: $(EXEC)
	echo 3 | sudo tee /proc/sys/vm/drop_caches
	watch -d -t "./phonebook_orig && echo 3 | sudo tee /proc/sys/vm/drop_caches"

cache-test: $(EXEC)
	perf stat --repeat 100 \
		-e cache-misses,cache-references,instructions,cycles \
		./phonebook_orig
	perf stat --repeat 100 \
		-e cache-misses,cache-references,instructions,cycles \
		./phonebook_opt
	perf stat --repeat 100 \
		-e cache-misses,cache-references,instructions,cycles \
		./phonebook_hash
	perf stat --repeat 100 \
		-e cache-misses,cache-references,instructions,cycles \
		./phonebook_trie
{'fraction_non_alphanumeric': 0.20232510707729962, 'fraction_numerical': 0.008158270446665308, 'mean_word_length': 3.643939393939394, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3272689', 'n_tokens_mistral': 2230, 'n_tokens_neox': 2078, 'n_words': 366}