<commit_before>ROOT=../../..
CPU=$(ROOT)/ve/cpu
BDIR=$(CPU)/bdir
BH_PYTHON=python

#
# Generate Doxygen documentation
docs:
	mkdir -p $(CPU)/doc/output
	cd $(CPU) && doxygen doc/cpu_engine.doxy

#
# Generate autogenerated code.
gen:
	mkdir -p $(CPU)/autogen/output
	cd $(CPU)/autogen && ./gen.py
	cp $(CPU)/autogen/output/utils_mapping.cpp $(CPU)/
	cp $(CPU)/autogen/output/specializer_cexpression.cpp $(CPU)/
	cp $(CPU)/autogen/output/instrs_to_tacs.cpp $(CPU)/utils_mapping_tacs.cpp
	cp $(CPU)/autogen/output/tac.cpp $(CPU)/tac.h
	rm $(CPU)/autogen/output/*.cpp

COMMON_CFLAGS=-Wall -Wno-unknown-pragmas -lm -std=c99
OMP_CFLAGS=-fopenmp -fopenmp-simd -openmp-report2 -ftree-vectorizer-verbose=2

basics_compile:
	gcc openmp/basics.c $(COMMON_CFLAGS) -O3 $(OMP_CFLAGS) -o bin/basics_O3_omp
	gcc openmp/basics.c $(COMMON_CFLAGS) -O2 $(OMP_CFLAGS) -o bin/basics_O2_omp
	gcc openmp/basics.c $(COMMON_CFLAGS) -O1 $(OMP_CFLAGS) -o bin/basics_O1_omp
	gcc openmp/basics.c $(COMMON_CFLAGS) -O0 $(OMP_CFLAGS) -o bin/basics_O0_omp
	gcc openmp/basics.c $(COMMON_CFLAGS) -O3 -o bin/basics_O3
	gcc openmp/basics.c $(COMMON_CFLAGS) -O2 -o bin/basics_O2
	gcc openmp/basics.c $(COMMON_CFLAGS) -O1 -o bin/basics_O1
	gcc openmp/basics.c $(COMMON_CFLAGS) -O0 -o bin/basics_O0

basics_run:
	@echo "O3"
	/usr/bin/time bin/basics_O3
	/usr/bin/time bin/basics_O3_omp
	@echo "O2"
	/usr/bin/time bin/basics_O2
	/usr/bin/time bin/basics_O2_omp
	@echo "O1"
	/usr/bin/time bin/basics_O1
	/usr/bin/time bin/basics_O1_omp
	@echo "O0"
	/usr/bin/time bin/basics_O0
	/usr/bin/time bin/basics_O0_omp

basics: basics_compile basics_run

purge_ko:
	rm -f ~/.local/var/bohrium/kernels/*
	rm -f ~/.local/var/bohrium/objects/*

purge_krn:
	rm -rf ~/.local/share/bohrium/templates
	rm -rf ~/.local/var/bohrium/kernels
	rm -rf ~/.local/var/bohrium/objects

#
# Remove installed stuff specific to the cpu-engine
purge_cpu:
	rm -rf ~/.local/share/bohrium/templates
	rm -rf ~/.local/var/bohrium/kernels
	rm -rf ~/.local/var/bohrium/objects
	rm -rf ~/.local/var/bohrium/scripts
	rm -f ~/.local/lib/libbh_ve_cpu.*
	rm -f ~/.local/include/bohrium/tac.h

#
# Remove everything
purge_all: purge_cpu
	cd $(ROOT) && git clean -fdx && git clean -fdX
	rm -rf $(BDIR)
	rm -rf ~/.local/bin
	rm -rf ~/.local/include
	rm -rf ~/.local/lib
	rm -rf ~/.local/share/bohrium
	rm -rf ~/.local/var
	rm -f ~/.bohrium/config.ini

#
# "Reinstall" the cpu-engine
#
reset_krn: purge_krn install
reset_cpu: purge_cpu install
reset_all: purge_all install

#
# "Install the cpu-engine
install:
	mkdir -p $(BDIR)
	cd $(BDIR) && cmake $(ROOT) && make && make install

#
# Clean up the build-files
clean:
	rm -rf $(BDIR) core trace-*.txt flow*.dot flow*.html graph-*.dot $(CPU)/doc/output $(CPU)/autogen/output/*

crap:<commit_msg>cpu: Added a purge_install tool.<commit_after>ROOT=../../..
CPU=$(ROOT)/ve/cpu
BDIR=$(CPU)/bdir
BH_PYTHON=python

#
# Generate Doxygen documentation
docs:
	mkdir -p $(CPU)/doc/output
	cd $(CPU) && doxygen doc/cpu_engine.doxy

#
# Generate autogenerated code.
gen:
	mkdir -p $(CPU)/autogen/output
	cd $(CPU)/autogen && ./gen.py
	cp $(CPU)/autogen/output/utils_mapping.cpp $(CPU)/
	cp $(CPU)/autogen/output/specializer_cexpression.cpp $(CPU)/
	cp $(CPU)/autogen/output/instrs_to_tacs.cpp $(CPU)/utils_mapping_tacs.cpp
	cp $(CPU)/autogen/output/tac.cpp $(CPU)/tac.h
	rm $(CPU)/autogen/output/*.cpp

COMMON_CFLAGS=-Wall -Wno-unknown-pragmas -lm -std=c99
OMP_CFLAGS=-fopenmp -fopenmp-simd -openmp-report2 -ftree-vectorizer-verbose=2

basics_compile:
	gcc openmp/basics.c $(COMMON_CFLAGS) -O3 $(OMP_CFLAGS) -o bin/basics_O3_omp
	gcc openmp/basics.c $(COMMON_CFLAGS) -O2 $(OMP_CFLAGS) -o bin/basics_O2_omp
	gcc openmp/basics.c $(COMMON_CFLAGS) -O1 $(OMP_CFLAGS) -o bin/basics_O1_omp
	gcc openmp/basics.c $(COMMON_CFLAGS) -O0 $(OMP_CFLAGS) -o bin/basics_O0_omp
	gcc openmp/basics.c $(COMMON_CFLAGS) -O3 -o bin/basics_O3
	gcc openmp/basics.c $(COMMON_CFLAGS) -O2 -o bin/basics_O2
	gcc openmp/basics.c $(COMMON_CFLAGS) -O1 -o bin/basics_O1
	gcc openmp/basics.c $(COMMON_CFLAGS) -O0 -o bin/basics_O0

basics_run:
	@echo "O3"
	/usr/bin/time bin/basics_O3
	/usr/bin/time bin/basics_O3_omp
	@echo "O2"
	/usr/bin/time bin/basics_O2
	/usr/bin/time bin/basics_O2_omp
	@echo "O1"
	/usr/bin/time bin/basics_O1
	/usr/bin/time bin/basics_O1_omp
	@echo "O0"
	/usr/bin/time bin/basics_O0
	/usr/bin/time bin/basics_O0_omp

basics: basics_compile basics_run

purge_ko:
	rm -f ~/.local/var/bohrium/kernels/*
	rm -f ~/.local/var/bohrium/objects/*

purge_krn:
	rm -rf ~/.local/share/bohrium/templates
	rm -rf ~/.local/var/bohrium/kernels
	rm -rf ~/.local/var/bohrium/objects

#
# Remove installed stuff specific to the cpu-engine
purge_cpu:
	rm -rf ~/.local/share/bohrium/templates
	rm -rf ~/.local/var/bohrium/kernels
	rm -rf ~/.local/var/bohrium/objects
	rm -rf ~/.local/var/bohrium/scripts
	rm -f ~/.local/lib/libbh_ve_cpu.*
	rm -f ~/.local/include/bohrium/tac.h

#
# Remove everything
purge_all: purge_cpu
	cd $(ROOT) && git clean -fdx && git clean -fdX
	rm -rf $(BDIR)
	rm -rf ~/.local/bin
	rm -rf ~/.local/include
	rm -rf ~/.local/lib
	rm -rf ~/.local/share/bohrium
	rm -rf ~/.local/var
	rm -f ~/.bohrium/config.ini

#
# "Reinstall" the cpu-engine
#
reset_krn: purge_krn install
reset_cpu: purge_cpu install
purge_install: purge_cpu purge_all clean gen install

#
# "Install the cpu-engine
install:
	mkdir -p $(BDIR)
	cd $(BDIR) && cmake $(ROOT) && make && make install

#
# Clean up the build-files
clean:
	rm -rf $(BDIR) core trace-*.txt flow*.dot flow*.html graph-*.dot $(CPU)/doc/output $(CPU)/autogen/output/*

crap:
{'fraction_non_alphanumeric': 0.1630963096309631, 'fraction_numerical': 0.01152115211521152, 'mean_word_length': 3.7285106382978723, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6574363', 'n_tokens_mistral': 2473, 'n_tokens_neox': 2425, 'n_words': 498}